QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#544496 | #9178. All-You-Can-Eat | gzchenben# | WA | 10ms | 4036kb | C++14 | 3.7kb | 2024-09-02 17:28:06 | 2024-09-02 17:28:07 |
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 && sum <= 1000) {
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.second != 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.rbegin()->first >= cur) {
printf("0\nIGNORE\n");
fflush(stdout);
continue;
}
vector<int> outp;
if (!L.size()) {
L.insert({ cur, i });
sum += cur;
}
else {
sum += cur - L.rbegin()->first;
auto It = L.end(); It--;
outp.push_back(It->second);
L.erase(It);
L.insert({ cur, i });
}
while (sum > 1000) {
sum -= S.back().first;
outp.push_back(S.back().second);
S.pop_back();
}
printf("%d ", outp.size());
for (auto p : outp) printf("%d ", p);
printf("\nTAKE\n");
fflush(stdout);
continue;
}
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
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: 4036kb
input:
1 1 100
output:
0 TAKE
result:
ok OK, worst = 1.000000 (1 test case)
Test #3:
score: -100
Wrong Answer
time: 10ms
memory: 3800kb
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 IGNOR...
result:
wrong answer alg = 535 opt = 1000 (test case 1)