QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#217157 | #7567. Joining Cats | LiZnB# | WA | 0ms | 3904kb | C++17 | 986b | 2023-10-16 16:00:39 | 2023-10-16 16:00:39 |
Judging History
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