QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#544479 | #9178. All-You-Can-Eat | gzchenben# | WA | 16ms | 3816kb | C++14 | 3.5kb | 2024-09-02 17:14:26 | 2024-09-02 17:14:28 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#include<set>
using namespace std;
int t, n;
vector<pair<int, int>> S, M; //<val, id>
multiset<pair<int, int>> L;
int main() {
int t;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
S.clear(); M.clear(); L.clear();
int sum = 0;
for (int i = 1;i <= n;i++) {
int cur;
scanf("%d", &cur);
if (sum >= 600) {
printf("0\nIGNORE\n");
fflush(stdout);
continue;
}
if (sum + cur >= 600 && sum + cur <= 1000) {
sum += cur;
printf("0\nTAKE\n");
fflush(stdout);
continue;
}
if (cur >= 600) {
printf("%d ", S.size() + M.size() + L.size());
for (auto p : S) printf("%d ", p.second);
for (auto p : M) printf("%d ", p.second);
for (auto p : L) printf("%d ", p.second);
sum = cur;
printf("\nTAKE\n");
fflush(stdout);
continue;
}
if (M.size() && cur >= 400) {
vector<int> outp;
for (auto p : S) outp.push_back(p.second);
for (auto p : M) if (p.first != M[0].second) outp.push_back(p.second);
sum = M[0].first + cur;
printf("%d ", outp.size());
for (auto p : outp) printf("%d ", p);
printf("\nTAKE\n");
fflush(stdout);
continue;
}
if (L.size() && cur >= 200 && cur < 400) {
vector<int> outp;
for (auto p : S) outp.push_back(p.second);
for (auto p : L) if (p.first != L.rbegin()->second) outp.push_back(p.second);
sum = L.rbegin()->first + cur;
printf("%d ", outp.size());
for (auto p : outp) printf("%d ", p);
printf("\nTAKE\n");
fflush(stdout);
continue;
}
if (cur < 200) {
S.push_back({ cur, i });
sum += cur;
printf("0\nTAKE\n");
fflush(stdout);
continue;
}
if (cur >= 200 && cur < 400) {
M.push_back({ cur, i });
sum += cur;
printf("0\nTAKE\n");
fflush(stdout);
continue;
}
if (cur >= 400 && cur < 600) {
if (!L.size()) {
L.insert({ cur, i });
sum += cur;
printf("0\nTAKE\n");
fflush(stdout);
continue;
}
if (L.rbegin()->first >= cur) {
printf("0\nIGNORE\n");
fflush(stdout);
continue;
}
else {
sum += cur - L.rbegin()->first;
auto It = L.end(); It--;
int lab = It->second;
L.erase(It);
L.insert({ cur, i });
printf("1 %d\nTAKE\n", lab);
fflush(stdout);
continue;
}
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3772kb
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: 0ms
memory: 3816kb
input:
1 1 100
output:
0 TAKE
result:
ok OK, worst = 1.000000 (1 test case)
Test #3:
score: -100
Wrong Answer
time: 16ms
memory: 3776kb
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 0 TAKE 0 TAKE 0 IGNORE 0 IGNORE 0 ...
result:
wrong answer alg = 535 opt = 1000 (test case 1)