QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605255#9178. All-You-Can-EatfosovTL 1ms3564kbC++143.2kb2024-10-02 16:24:492024-10-02 16:24:50

Judging History

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

  • [2024-10-02 16:24:50]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3564kb
  • [2024-10-02 16:24:49]
  • 提交

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);
        };

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

            if (sum() >= 600) {
                cout << "0\nIGNORE\n";
                cout.flush();
                continue;
            }

            // 0-299 300-599 600-1000 
            if (a < 300) {
                bk[0].emplace_back(i, a);
                bksum[0] += a;
                cout << "0\nTAKE\n";
                cout.flush();
            } else if (a < 600) {
                if (bk[1].size() == 0) {
                    bk[1].emplace_back(i, a);
                    bksum[1] += a;

                    vector<int> idxs;
                    while (sum() > 1000) {
                        idxs.emplace_back(bk[0].back().first);
                        bksum[0] -= bk[0].back().second;
                        bk[0].pop_back();
                    }
                    cout << idxs.size() << ' ';
                    for (auto idx : idxs) cout << idx << ' ';
                    cout << "\nTAKE\n";
                    cout.flush();
                } else if (bk[1].size() == 1) {
                    if (bksum[1] + a <= 1000) {
                        cout << bk[0].size() << ' ';
                        for (auto [idx, x] : bk[0]) cout << idx << ' ';
                        cout << "\nTAKE\n";
                        cout.flush();

                        bk[0].clear(), bksum[0] = 0;
                        bk[1].emplace_back(i, a);
                        bksum[1] += a;
                    } else {
                        if (bk[1][0].second > a) {
                            cout << "0\nIGNORE\n";
                        } else {
                            cout << bk[1].size() << ' ';
                            for (auto [idx, x] : bk[1]) cout << idx << ' ';
                            cout << "\nTAKE\n";
                            cout.flush();

                            bk[1].clear(), bksum[1] = 0;
                            bk[1].emplace_back(i, a);
                            bksum[1] += a;
                        }
                    }
                } else {
                    assert(0);
                }

            } else {
                cout << bk[0].size() + bk[1].size() << ' ';
                for (auto [idx, x] : bk[0]) cout << idx << ' ';
                for (auto [idx, x] : bk[1]) cout << idx << ' ';
                cout << "\nTAKE\n";
                cout.flush();

                bk[0].clear(), bksum[0] = 0;
                bk[1].clear(), bksum[1] = 0;
                bk[2].emplace_back(i, a);
                bksum[2] += a;
            }
        }
        
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
5
10
13
450
585
465

output:

0
TAKE
0
TAKE
0 
TAKE
1 3 
TAKE
0
IGNORE

result:

ok OK, worst = 0.648188 (1 test case)

Test #2:

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

input:

1
1
100

output:

0
TAKE

result:

ok OK, worst = 1.000000 (1 test case)

Test #3:

score: -100
Time Limit Exceeded

input:

2000
5
535
529

output:

0 
TAKE

result: