QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543601#9178. All-You-Can-EatdsbdsbWA 1ms3856kbC++141.6kb2024-09-01 17:26:332024-09-01 17:26:39

Judging History

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

  • [2024-09-01 17:26:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3856kb
  • [2024-09-01 17:26:33]
  • 提交

answer

#include<bits/stdc++.h>
#define cfl cout.flush()
#define pb push_back
#define N 1010
using namespace std;
int a[N*10],n,f[N],m=1000,pre[N],sum,used[N*10],ans;
vector<int> op;
vector<int>::iterator it;

int main(){
	int T;
	cin>>T;
	while(T--){
		cin>>n;
		memset(f,0,sizeof f);
		ans=0;
		f[0]=1;
		sum=0;
		int fl=0,fz;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			if(fl){
				cout<<"0\nIGNORE\n";
				cfl;
				continue;
			}
			for(int j=m;j>=a[i];j--){
				if(f[j-a[i]]) f[j]=1;
				if(f[j]&&j>ans) ans=j;
			}
			sum+=a[i];
			if(sum>600&&sum<=1000){
				fl=1;
				cout<<"0\nTAKE\n";
				continue;
				cfl;
			}
			used[i]=1;
			fz=(ans*3/5)+1;
			fz=sum-fz;
			memset(pre,0,sizeof pre);
			pre[0]=n+1;
			int qfz=0;
			for(int j=1;j<=i;j++) if(used[j]){
				for(int k=fz;k>=a[j];k--) if(pre[k-a[j]]&&!pre[k]) pre[k]=j;
				if(pre[fz]){
					qfz=1;
					break;
				}
			}
			printf("%d %d %d !!!\n",fz,qfz,sum);
			vector<int>().swap(op);
			if(qfz){
				int cur=fz;
				sum-=cur;
				while(cur){
					printf("%d %d !\n",cur,pre[cur]);
					used[pre[cur]]=0;
					if(pre[cur]!=i) op.pb(pre[cur]);
					cur-=a[pre[cur]];
				}
			}
			else{
				for(int j=fz;j>=0;j--) if(pre[j]){
					int cur=j;
					sum-=cur;
					while(cur){
						printf("%d %d !!\n",cur,pre[cur]);
						used[pre[cur]]=0;
						if(pre[cur]!=i) op.pb(pre[cur]);
						cur-=a[pre[cur]];
					}
					break;
				}
			}
			cout<<op.size()<<' ';
			for(auto tt:op) cout<<tt<<' ';
			if(used[i]) cout<<"\nTAKE\n";
			else cout<<"\nIGNORE\n";
			cfl;
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3856kb

input:

1
5
10

output:

3 0 10 !!!
0 
TAKE

result:

wrong output format Unexpected end of file - int32 expected (test case 1)