QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605339#9178. All-You-Can-EatfosovWA 17ms3820kbC++142.8kb2024-10-02 16:45:282024-10-02 16:45:28

Judging History

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

  • [2024-10-02 16:45:28]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3820kb
  • [2024-10-02 16:45:28]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

#define ll long long 
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353

#define N 5050

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t; cin >> t;
    while (t --) {
        int n; cin >> n;

        vector<vector<pair<int, int>>> bk(3);
        vector<int> bksum(3, 0);
        int tot = 0;

        auto sum = [&]() {
            return accumulate(bksum.begin(), bksum.end(), 0);
        };

        auto add = [&](int bkid, int i, int a) {
            bk[bkid].emplace_back(i, a);
            bksum[bkid] += a;
        };

        auto pop_back = [&](int bkid, vector<int>& cont) {
            cont.emplace_back(bk[bkid].back().first);
            int val = bk[bkid].back().second;
            bksum[bkid] -= val;
            return val;
        };

        auto pop_clear = [&](int bkid, vector<int>& cont) {
            for (auto [idx, x] : bk[bkid]) cont.emplace_back(idx);
            bk[bkid].clear();
            bksum[bkid] = 0;
        };

        auto print = [&](bool take, vector<int>& cont) {
            cout << cont.size() << ' ';
            for (auto x : cont) cout << x << ' ';
            cout << (take ? "\nTAKE\n" : "\nIGNORE\n");
        };

        for (int i = 1; i <= n; ++ i) {
            int a; cin >> a;
            vector<int> rm;

            if (sum() >= 600) {
                print(0, rm);
                cout.flush();
                continue;
            }

            // 0-299 300-599 600-1000 
            if (a < 400) {
                add(0, i, a);
                print(1, rm);
            } else if (a < 600) {
                if (bk[1].size() == 0) {
                    add(1, i, a);
                    while (sum() > 1000) pop_back(0, rm);
                    print(1, rm);
                } else if (bk[1].size() == 1) {
                    if (bksum[1] + a <= 1000) {
                        pop_clear(0, rm);
                        add(1, i, a);
                        print(1, rm);
                    } else {
                        if (bk[1][0].second <= a) {
                            print(0, rm);
                        } else {
                            pop_clear(1, rm);
                            add(1, i, a);
                            print(1, rm);
                        }
                    }
                } else {
                    assert(0);
                }
            } else {
                pop_clear(0, rm);
                pop_clear(1, rm);
                add(2, i, a);
                print(1, rm);
            }
            cout.flush();
        }
        
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3756kb

input:

1
5
10
13
450
585
465

output:

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

result:

ok OK, worst = 0.975480 (1 test case)

Test #2:

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

input:

1
1
100

output:

0 
TAKE

result:

ok OK, worst = 1.000000 (1 test case)

Test #3:

score: 0
Accepted
time: 10ms
memory: 3528kb

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 
I...

result:

ok OK, worst = 0.836394 (2000 test cases)

Test #4:

score: 0
Accepted
time: 17ms
memory: 3748kb

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...

result:

ok OK, worst = 0.836394 (500 test cases)

Test #5:

score: 0
Accepted
time: 10ms
memory: 3532kb

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...

result:

ok OK, worst = 0.836394 (200 test cases)

Test #6:

score: 0
Accepted
time: 11ms
memory: 3624kb

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...

result:

ok OK, worst = 0.836394 (100 test cases)

Test #7:

score: 0
Accepted
time: 6ms
memory: 3616kb

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...

result:

ok OK, worst = 0.836394 (10 test cases)

Test #8:

score: 0
Accepted
time: 9ms
memory: 3532kb

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...

result:

ok OK, worst = 0.836394 (1 test case)

Test #9:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

1
2
2
999

output:

0 
TAKE
1 1 
TAKE

result:

ok OK, worst = 1.000000 (1 test case)

Test #10:

score: 0
Accepted
time: 2ms
memory: 3616kb

input:

100
3
551
450
550
3
552
449
551
3
553
448
552
3
554
447
553
3
555
446
554
3
556
445
555
3
557
444
556
3
558
443
557
3
559
442
558
3
560
441
559
3
561
440
560
3
562
439
561
3
563
438
562
3
564
437
563
3
565
436
564
3
566
435
565
3
567
434
566
3
568
433
567
3
569
432
568
3
570
431
569
3
571
430
570
3
...

output:

0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
TAKE
0 
TAKE
0 
TAKE
1 1 
T...

result:

ok OK, worst = 0.600000 (100 test cases)

Test #11:

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

input:

41
238
1
0
0
4
1
2
0
5
0
5
1
5
2
3
5
1
1
5
5
2
1
3
4
1
5
0
4
1
5
3
1
4
4
1
1
4
2
2
1
0
4
1
5
1
2
4
3
4
0
2
2
0
3
3
4
2
2
1
2
0
3
5
3
3
1
2
4
3
3
3
0
3
1
1
0
4
5
4
1
3
5
2
0
1
0
2
3
0
5
4
5
5
5
1
5
5
5
2
1
4
0
0
4
3
2
5
0
4
1
1
5
3
5
2
3
1
3
3
0
2
3
1
2
3
5
0
5
2
3
5
3
0
3
4
1
0
1
3
1
2
0
4
5
4
3
0
4...

output:

0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
TAKE
0 
T...

result:

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