QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238730#7567. Joining Catsucup-team1074WA 0ms3688kbC++20867b2023-11-04 17:22:112023-11-04 17:22:13

Judging History

你现在查看的是最新测评结果

  • [2023-11-04 17:22:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2023-11-04 17:22:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005;
int n,k,l[N],r[N],w[N];
ll sum[N],s[N];
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
int main(){
    cin>>n>>k;
    For(i,1,n)cin>>w[i];//读取
    For(i,1,n)sum[i]=sum[i-1]+w[i];//前缀和
    For(i,1,k)cin>>s[i];//风
    For(i,1,n)r[i]=l[i]=i;//从i向右合并,从i向左合并
    For(o,1,k){
        For(i,1,n){
            int tmp=r[i];
            while(r[i] < n && sum[r[i]+1] - sum[tmp] <= s[o])r[i]++;
            tmp=l[i];
            while(l[i] > 1 && sum[tmp-1] - sum[l[i]-2] <= s[o])l[i]--;
        }
   //     For(i,1,n){l[r[i]]=min(l[r[i]],i); r[l[i]]=max(r[l[i]],i);}
        //For(i,1,n)cout<<l[i]<<" "<<i<<endl;
    }  
    if(r[1]==n)puts("Yes"); else puts("No");

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

5 2
1 1 1 1 1
2 2

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

6 7
3 2 1 1 2 3
2 2 2 2 2 2 2

output:

No

result:

ok answer is NO

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

7 4
1 2 3 4 3 2 1
3 3 3 3

output:

No

result:

wrong answer expected YES, found NO