QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#605317 | #9178. All-You-Can-Eat | fosov | WA | 13ms | 3592kb | C++14 | 2.8kb | 2024-10-02 16:40:59 | 2024-10-02 16:40:59 |
Judging History
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;
if (sum() >= 600) {
cout << "0\nIGNORE\n";
cout.flush();
continue;
}
vector<int> rm;
// 0-299 300-599 600-1000
if (a < 300) {
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: 3592kb
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: 3588kb
input:
1 1 100
output:
0 TAKE
result:
ok OK, worst = 1.000000 (1 test case)
Test #3:
score: -100
Wrong Answer
time: 13ms
memory: 3560kb
input:
2000 5 535 529 471 0 0 5 536 588 464 0 0 5 558 515 485 0 0 5 525 599 475 0 0 5 507 549 493 0 0 5 561 567 439 0 0 5 504 557 496 0 0 5 596 592 408 0 0 5 503 549 497 0 0 5 549 536 464 0 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 477 0 0 5 577 5...
output:
0 TAKE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 IGNORE 0 TAKE ...
result:
wrong answer alg = 535 opt = 1000 (test case 1)