QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543533#9178. All-You-Can-EatnekoyellowWA 24ms3860kbC++201.9kb2024-09-01 17:06:542024-09-01 17:06:54

Judging History

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

  • [2024-09-01 17:06:54]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3860kb
  • [2024-09-01 17:06:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int query() {
    int ai;
    if (!(cin >> ai)) exit(0);
    return ai;
}

void solve() {
    int n;
    cin >> n;
    set<pii> a; int sum = 0;
    for (int i = 1; i <= n; i++) {
        int e = query();
        if (sum >= 600) {
            cout << "0\nIGNORE\n" << endl;
            continue;
        }
        if (e >= 600) {
            cout << a.size();
            for (auto [_, i]: a) cout << i << ' ';
            cout << endl;
            a.clear();
            a.emplace(e, i);
            sum = e;
            cout << "TAKE\n" << endl;
            continue;
        }
        if (e <= 401) {
            cout << "0\nTAKE\n" << endl;
            a.emplace(e, i);
            sum += e;
            continue;
        }
        if (e >= 500) {
            if (a.size() && a.begin()->first <= sum) {
                cout << "0\nIGNORE\n" << endl;
            } else if (a.size()) {
                cout << 1 << ' ' << a.begin()->second << endl;
                a.extract(a.begin());
                sum -= a.begin()->first;
                a.emplace(e, i);
                sum += e;
                cout << "TAKE\n" << endl;
            } else {
                cout << "0\nTAKE\n" << endl;
                a.emplace(e, i);
                sum += e;
            }
            continue;
        }
        vector<int> topop;
        while (sum + e > 1000) {
            auto [v, i] = *a.begin();
            a.extract(a.begin());
            topop.push_back(i);
            sum -= v;
        }
        cout << topop.size();
        for (auto i: topop) cout << ' ' << i;
        cout << endl;
        cout << "TAKE\n" << endl;
        a.emplace(e, i);
        sum += e;
    }
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int t;
    cin >> t;
    for (; t; t--) solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 3860kb

input:

1
1
100

output:

0
TAKE


result:

ok OK, worst = 1.000000 (1 test case)

Test #3:

score: -100
Wrong Answer
time: 24ms
memory: 3568kb

input:

2000
5
535
529
471
0
0
5
536
588
558
515
485
5
525
599
507
493
0
5
549
561
567
504
496
5
557
596
592
503
497
5
549
549
536
464
0
5
590
572
428
0
0
5
589
540
460
0
0
5
544
524
476
0
0
5
553
545
455
0
0
5
555
543
457
0
0
5
523
571
577
506
494
5
594
519
481
0
0
5
527
521
479
0
0
5
587
539
461
0
0
5
561...

output:

0
TAKE

0
IGNORE

1 1
TAKE

0
TAKE

0
TAKE

0
TAKE

0
IGNORE

0
IGNORE

0
IGNORE

1 1
TAKE

0
TAKE

0
IGNORE

0
IGNORE

1 1
TAKE

0
TAKE

0
TAKE

0
IGNORE

0
IGNORE

0
IGNORE

1 1
TAKE

0
TAKE

0
IGNORE

0
IGNORE

0
IGNORE

1 1
TAKE

0
TAKE

0
IGNORE

0
IGNORE

1 1
TAKE

0
TAKE

0
TAKE

0
IGNORE

1 ...

result:

wrong answer alg = 471 opt = 1000 (test case 1)