输?入?出?了?问?题?

P1314 [NOIP2011 提高组] 聪明的质监员

wmq2006 @ 2020-07-24 22:05:20

洛谷IDE居然显示输入长度不合法???

比如2500 4300的数据就显示输入长度不合法,而输入相同的题解就不会

真的快疯了,一个题代码写了20分钟调这个错两个小时

好心人能帮着看看吗qwq

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdio>

using namespace std;
int w[300001],v[300001],l[300001],r[300001],n,m,s;
long long qw[200001]={0},qv[200001]={0};
long long ans=1e18,answ=0;
long long u=0,d=1e18,mid;
long long check(int k){
    long long cnt=0;
    for(int i=1;i<=n;i++)qw[i]=0,qv[i]=0;
    for(int i=1;i<=n;i++){
        if(w[i]>=k){
            qw[i]=qw[i-1]+1;
            qv[i]=qv[i-1]+v[i];
        }
        else{
            qw[i]=qw[i-1];
            qv[i]=qv[i-1];
        }
    }
    for(int i=1;i<=m;i++)cnt+=(qv[r[i]]-qv[l[i]-1])*(qw[r[i]]-qw[l[i]-1]);
    return cnt;
}
int main(){
    //freopen("bird.in","r",stdin);
    //freopen("bird.out","w",stdout);
    cin>>n>>m>>s;
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
        //u=max(u,w[i]);
        //d=min(d,w[i]);
    }
    u=1e6;
    d=0;
    for(int i=1;i<=m;i++)cin>>l[i]>>r[i];
    while(d<u){
        mid=(u+d)/2;
        //cout<<mid<<" "<<check(mid)<<endl;
        if(check(mid)<s)u=mid-1;
        if(check(mid)>s)d=mid+1;
        if(abs(check(mid)-s)<ans)ans=abs(check(mid)-s);
        if(check(mid)==s){cout<<ans<<endl;return 0;}
    }
    cout<<ans<<endl;
    return 0;
}

by yummy @ 2020-07-24 22:18:20

@wmq2006 别用你谷IDE,你谷IDE本来就不能测试大数据,用本地IDE吧


by wmq2006 @ 2020-07-24 22:27:17

@yummy LINUX也不行


by RE—自动机 @ 2020-08-04 10:13:04

直接提交一下吧


|