QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543624#9178. All-You-Can-EatKJGKMTZBWA 24ms3848kbC++141.6kb2024-09-01 17:34:462024-09-01 17:34:46

Judging History

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

  • [2024-09-01 17:34:46]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3848kb
  • [2024-09-01 17:34:46]
  • 提交

answer

#include<bits/stdc++.h>
const int N=11e4;
using ll=long long;
using namespace std;
#define up(a,b,c) for(int a=b;a<=c;++a)
#define dn(a,b,c) for(int a=b;a>=c;--a)
int T,n,a[N],sm,ot;
bool ok;
vector<int>ccf;
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>n;ok=0,sm=0,ot=0,ccf.clear();
		up(i,1,n)
		{
			cin>>a[i];
			if(sm>=600)ok=1;
			if(ok)
			{
				cout<<"0"<<endl;
				cout<<"IGNORE"<<endl;
				continue;
			}
			if(a[i]>=600)
			{
				ok=1;
				cout<<ccf.size()+bool(ot);
				for(int x:ccf)
					cout<<' '<<x;
				cout<<' '<<ot;
				cout<<endl;
				ccf.clear(),sm=a[i],ot=i;
				cout<<"TAKE"<<endl,ok=1;
			}
			else if(a[i]<=400)
			{
				if(sm+a[i]<=1000)
				{
					cout<<0<<endl;
					cout<<"TAKE"<<endl,sm+=a[i],ccf.push_back(i);
				}
				else
				{
					cout<<0<<endl;
					cout<<"IGNORE"<<endl,ok=1;
				}
			}
			else
			{
				if(sm+a[i]<=1000)
				{
					cout<<0<<endl;
					cout<<"TAKE"<<endl,sm+=a[i],ot=i;
				}
				else
				{
					if(!ccf.empty()&&a[ot]+a[i]<=1000)
					{
						vector<int>noi;
						int cc=0;sm+=a[i];
						while(!ccf.empty()&&sm>1000)
							++cc,noi.push_back(ccf.back()),sm-=a[ccf.back()],ccf.pop_back();
						cout<<cc;
						for(int z:noi)cout<<' '<<z;
						cout<<endl;
						cout<<"TAKE"<<endl,ot=i,ok=1;
					}
					else
					{
						if(a[i]<a[ot])
						{
							cout<<1<<' '<<ot<<endl,sm+=a[i]-a[ot],ot=i;
							cout<<"TAKE"<<endl;
						}
						else
						{
							cout<<0<<endl;
							cout<<"IGNORE"<<endl;
						}
					}
				}
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
5
10
13
450
585
465

output:

0
TAKE
0
TAKE
0
TAKE
0
IGNORE
0
TAKE

result:

ok OK, worst = 1.000000 (1 test case)

Test #2:

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

input:

1
1
100

output:

0
TAKE

result:

ok OK, worst = 1.000000 (1 test case)

Test #3:

score: 0
Accepted
time: 24ms
memory: 3520kb

input:

2000
5
535
529
536
588
558
5
515
525
599
507
549
5
561
567
504
557
596
5
592
503
549
549
536
5
590
572
589
540
544
5
524
553
545
555
543
5
523
571
577
506
594
5
519
527
521
587
539
5
561
569
573
552
587
5
571
515
585
525
589
5
512
572
565
516
527
5
573
579
564
514
557
5
518
595
509
518
549
5
549
541...

output:

0
TAKE
1 1
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
TAKE
0
IGNORE
0
IGNORE
1 1
TAKE
0
IGNORE
0
TAKE
0
IGNORE
1 1
TAKE
0
IGNORE
0
IGNORE
0
TAKE
1 1
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
TAKE
1 1
TAKE
0
IGNORE
1 2
TAKE
0
IGNORE
0
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
TAKE
0
IGNORE
0
IGNORE
1 1
TAKE
0
IGNORE...

result:

ok OK, worst = 0.836394 (2000 test cases)

Test #4:

score: 0
Accepted
time: 15ms
memory: 3496kb

input:

500
20
535
529
536
588
558
515
525
599
507
549
561
567
504
557
596
592
503
549
549
536
20
590
572
589
540
544
524
553
545
555
543
523
571
577
506
594
519
527
521
587
539
20
561
569
573
552
587
571
515
585
525
589
512
572
565
516
527
573
579
564
514
557
20
518
595
509
518
549
549
541
580
535
531
540
...

output:

0
TAKE
1 1
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 2
TAKE
0
IGNORE
0
IGNORE
1 6
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 9
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 13
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
TAKE
1 1
TAKE
0
IGNORE
1 2
TAKE
0
IGNORE
1 4
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
1 6
TAKE
0
IGNORE
0
IGNORE
1 11
T...

result:

ok OK, worst = 0.836394 (500 test cases)

Test #5:

score: 0
Accepted
time: 15ms
memory: 3552kb

input:

200
50
535
529
536
588
558
515
525
599
507
549
561
567
504
557
596
592
503
549
549
536
590
572
589
540
544
524
553
545
555
543
523
571
577
506
594
519
527
521
587
539
561
569
573
552
587
571
515
585
525
589
50
512
572
565
516
527
573
579
564
514
557
518
595
509
518
549
549
541
580
535
531
540
596
51...

output:

0
TAKE
1 1
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 2
TAKE
0
IGNORE
0
IGNORE
1 6
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 9
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 13
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IG...

result:

ok OK, worst = 0.836394 (200 test cases)

Test #6:

score: 0
Accepted
time: 13ms
memory: 3780kb

input:

100
100
535
529
536
588
558
515
525
599
507
549
561
567
504
557
596
592
503
549
549
536
590
572
589
540
544
524
553
545
555
543
523
571
577
506
594
519
527
521
587
539
561
569
573
552
587
571
515
585
525
589
512
572
565
516
527
573
579
564
514
557
518
595
509
518
549
549
541
580
535
531
540
596
516
...

output:

0
TAKE
1 1
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 2
TAKE
0
IGNORE
0
IGNORE
1 6
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 9
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 13
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IG...

result:

ok OK, worst = 0.836394 (100 test cases)

Test #7:

score: 0
Accepted
time: 8ms
memory: 3784kb

input:

10
1000
535
529
536
588
558
515
525
599
507
549
561
567
504
557
596
592
503
549
549
536
590
572
589
540
544
524
553
545
555
543
523
571
577
506
594
519
527
521
587
539
561
569
573
552
587
571
515
585
525
589
512
572
565
516
527
573
579
564
514
557
518
595
509
518
549
549
541
580
535
531
540
596
516
...

output:

0
TAKE
1 1
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 2
TAKE
0
IGNORE
0
IGNORE
1 6
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 9
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 13
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IG...

result:

ok OK, worst = 0.836394 (10 test cases)

Test #8:

score: 0
Accepted
time: 14ms
memory: 3660kb

input:

1
10000
535
529
536
588
558
515
525
599
507
549
561
567
504
557
596
592
503
549
549
536
590
572
589
540
544
524
553
545
555
543
523
571
577
506
594
519
527
521
587
539
561
569
573
552
587
571
515
585
525
589
512
572
565
516
527
573
579
564
514
557
518
595
509
518
549
549
541
580
535
531
540
596
516
...

output:

0
TAKE
1 1
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 2
TAKE
0
IGNORE
0
IGNORE
1 6
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 9
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
1 13
TAKE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IGNORE
0
IG...

result:

ok OK, worst = 0.836394 (1 test case)

Test #9:

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

input:

1
2
2
999

output:

0
TAKE
1 1 0
TAKE

result:

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