QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#545180 | #9178. All-You-Can-Eat | gzchenben | WA | 18ms | 4108kb | C++14 | 3.6kb | 2024-09-02 23:50:12 | 2024-09-02 23:50:12 |
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, L; //<val, id>
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.second != L[0].second) outp.push_back(p.second);
sum = L[0].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[0].first <= cur) {
printf("0\nIGNORE\n");
fflush(stdout);
continue;
}
vector<int> outp;
if (!L.size()) {
L.push_back({ cur, i });
sum += cur;
}
else {
sum += cur - L[0].first;
outp.push_back(L[0].second);
L.pop_back();
L.push_back({ 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;
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4096kb
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: 0ms
memory: 4032kb
input:
1 1 100
output:
0 TAKE
result:
ok OK, worst = 1.000000 (1 test case)
Test #3:
score: 0
Accepted
time: 18ms
memory: 3804kb
input:
2000 5 535 529 536 588 558 5 515 525 599 507 549 5 561 567 504 557 596 5 592 503 549 549 536 5 590 572 589 540 544 5 524 553 545 555 543 5 523 571 577 506 594 5 519 527 521 587 539 5 561 569 573 552 587 5 571 515 585 525 589 5 512 572 565 516 527 5 573 579 564 514 557 5 518 595 509 518 549 5 549 541...
output:
0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 IGNORE 0 IGNORE 1 1 TAKE 0 IGNORE 0 TAKE 0 IGNORE 1 1 TAKE 0 IGNORE 0 IGNORE 0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 1 1 TAKE 0 IGNORE 1 2 TAKE 0 IGNORE 0 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 IGNORE 0 IGNORE 1 1 ...
result:
ok OK, worst = 0.836394 (2000 test cases)
Test #4:
score: 0
Accepted
time: 6ms
memory: 4108kb
input:
500 20 535 529 536 588 558 515 525 599 507 549 561 567 504 557 596 592 503 549 549 536 20 590 572 589 540 544 524 553 545 555 543 523 571 577 506 594 519 527 521 587 539 20 561 569 573 552 587 571 515 585 525 589 512 572 565 516 527 573 579 564 514 557 20 518 595 509 518 549 549 541 580 535 531 540 ...
output:
0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 2 TAKE 0 IGNORE 0 IGNORE 1 6 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 9 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 13 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 1 1 TAKE 0 IGNORE 1 2 TAKE 0 IGNORE 1 4 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 1 6 TAKE 0 IGNORE 0 IG...
result:
ok OK, worst = 0.836394 (500 test cases)
Test #5:
score: 0
Accepted
time: 7ms
memory: 4100kb
input:
200 50 535 529 536 588 558 515 525 599 507 549 561 567 504 557 596 592 503 549 549 536 590 572 589 540 544 524 553 545 555 543 523 571 577 506 594 519 527 521 587 539 561 569 573 552 587 571 515 585 525 589 50 512 572 565 516 527 573 579 564 514 557 518 595 509 518 549 549 541 580 535 531 540 596 51...
output:
0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 2 TAKE 0 IGNORE 0 IGNORE 1 6 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 9 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 13 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNOR...
result:
ok OK, worst = 0.836394 (200 test cases)
Test #6:
score: 0
Accepted
time: 7ms
memory: 4104kb
input:
100 100 535 529 536 588 558 515 525 599 507 549 561 567 504 557 596 592 503 549 549 536 590 572 589 540 544 524 553 545 555 543 523 571 577 506 594 519 527 521 587 539 561 569 573 552 587 571 515 585 525 589 512 572 565 516 527 573 579 564 514 557 518 595 509 518 549 549 541 580 535 531 540 596 516 ...
output:
0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 2 TAKE 0 IGNORE 0 IGNORE 1 6 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 9 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 13 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNOR...
result:
ok OK, worst = 0.836394 (100 test cases)
Test #7:
score: 0
Accepted
time: 3ms
memory: 3824kb
input:
10 1000 535 529 536 588 558 515 525 599 507 549 561 567 504 557 596 592 503 549 549 536 590 572 589 540 544 524 553 545 555 543 523 571 577 506 594 519 527 521 587 539 561 569 573 552 587 571 515 585 525 589 512 572 565 516 527 573 579 564 514 557 518 595 509 518 549 549 541 580 535 531 540 596 516 ...
output:
0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 2 TAKE 0 IGNORE 0 IGNORE 1 6 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 9 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 13 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNOR...
result:
ok OK, worst = 0.836394 (10 test cases)
Test #8:
score: 0
Accepted
time: 0ms
memory: 4068kb
input:
1 10000 535 529 536 588 558 515 525 599 507 549 561 567 504 557 596 592 503 549 549 536 590 572 589 540 544 524 553 545 555 543 523 571 577 506 594 519 527 521 587 539 561 569 573 552 587 571 515 585 525 589 512 572 565 516 527 573 579 564 514 557 518 595 509 518 549 549 541 580 535 531 540 596 516 ...
output:
0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 2 TAKE 0 IGNORE 0 IGNORE 1 6 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 9 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 1 13 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNOR...
result:
ok OK, worst = 0.836394 (1 test case)
Test #9:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
1 2 2 999
output:
0 TAKE 1 1 TAKE
result:
ok OK, worst = 1.000000 (1 test case)
Test #10:
score: 0
Accepted
time: 1ms
memory: 3864kb
input:
100 3 551 450 550 3 552 449 551 3 553 448 552 3 554 447 553 3 555 446 554 3 556 445 555 3 557 444 556 3 558 443 557 3 559 442 558 3 560 441 559 3 561 440 560 3 562 439 561 3 563 438 562 3 564 437 563 3 565 436 564 3 566 435 565 3 567 434 566 3 568 433 567 3 569 432 568 3 570 431 569 3 571 430 570 3 ...
output:
0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE 0 TAKE 1 1 TAKE 0 TAKE ...
result:
ok OK, worst = 0.600000 (100 test cases)
Test #11:
score: 0
Accepted
time: 9ms
memory: 3824kb
input:
41 238 1 0 0 4 1 2 0 5 0 5 1 5 2 3 5 1 1 5 5 2 1 3 4 1 5 0 4 1 5 3 1 4 4 1 1 4 2 2 1 0 4 1 5 1 2 4 3 4 0 2 2 0 3 3 4 2 2 1 2 0 3 5 3 3 1 2 4 3 3 3 0 3 1 1 0 4 5 4 1 3 5 2 0 1 0 2 3 0 5 4 5 5 5 1 5 5 5 2 1 4 0 0 4 3 2 5 0 4 1 1 5 3 5 2 3 1 3 3 0 2 3 1 2 3 5 0 5 2 3 5 3 0 3 4 1 0 1 3 1 2 0 4 5 4 3 0 4...
output:
0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE 0 TAKE...
result:
ok OK, worst = 0.996000 (41 test cases)
Test #12:
score: -100
Wrong Answer
time: 5ms
memory: 3800kb
input:
2000 5 174 966 564 649 8 5 58 211 929 70 340 5 481 864 73 407 722 5 181 417 607 419 28 5 429 40 935 257 913 5 387 532 505 446 80 5 187 486 713 23 81 5 61 330 611 918 736 5 939 19 164 889 679 5 847 644 540 944 848 5 618 224 362 561 336 5 504 875 211 808 227 5 104 528 433 537 106 5 997 485 442 729 421...
output:
0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 2 1 2 TAKE 0 IGNORE 0 IGNORE 0 TAKE 1 1 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 2 1 2 TAKE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 2 2 1 TAKE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 IGNORE 0 IGNORE 0 IG...
result:
wrong answer alg = 574 opt = 972 (test case 82)