QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217157#7567. Joining CatsLiZnB#WA 0ms3904kbC++17986b2023-10-16 16:00:392023-10-16 16:00:39

Judging History

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

  • [2023-10-16 16:00:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3904kb
  • [2023-10-16 16:00:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5050;
long long a[N],s[N];
bool dfs(int pos,int l,int r){
    printf("%d %d %d\n",pos,l,r);
    if(l>=r-1)return true;
    if(pos==-1){
        return false;
    }
    long long lsum=0,rsum=0,lpos=l,rpos=r-1;
    while(lpos<r){
        if(lsum+a[lpos]<=s[pos]){
            lsum+=a[lpos];
        }else{
            lpos--;
            break;
        }
        lpos++;
    }
    while(rpos>=l){
        if(rsum+a[rpos]<=s[pos]){
            rsum+=a[rpos];
        }else{
            rpos++;
            break;
        }
        rpos--;
    }
    if(lsum<rsum){
        return dfs(pos-1,l,rpos);
    }else{
        return dfs(pos-1,lpos+1,r);
    }
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    for(int i=0;i<k;i++)scanf("%lld",&s[i]);
    bool can=dfs(k-1,0,n);
    if(can)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3904kb

input:

5 2
1 1 1 1 1
2 2

output:

1 0 5
0 2 5
-1 4 5
Yes

result:

wrong output format YES or NO expected, but 1 found