QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#516943 | #9178. All-You-Can-Eat | ucup-team1198# | WA | 7ms | 3612kb | C++20 | 1.9kb | 2024-08-13 00:47:13 | 2024-08-13 00:47:13 |
Judging History
answer
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
const int M = 1000;
const int NEED = 600;
void solve() {
int n;
cin >> n;
vector<pair<int, int>> cur; // (val, ind)
vector<pair<int, int>> new_cur;
vector<int> leave;
int cur_sum = 0;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
cur_sum += x;
cur.emplace_back(x, i);
if (cur_sum <= M) {
cout << 0 << '\n';
cout << "TAKE" << endl;
} else {
sort(cur.rbegin(), cur.rend());
new_cur.clear();
leave.clear();
cur_sum = 0;
for (auto [x, i] : cur) {
if (cur_sum + x <= M) {
cur_sum += x;
new_cur.emplace_back(x, i);
} else {
leave.emplace_back(i);
}
}
if (cur_sum >= NEED) {
bool leave_cur = false;
for (int j : leave) {
if (j == i)
leave_cur = true;
}
cout << int(leave.size()) - leave_cur << ' ';
for (int j : leave) {
if (j != i)
cout << j + 1 << ' ';
}
cout << '\n';
if (leave_cur)
cout << "IGNORE";
else
cout << "TAKE";
cout << endl;
swap(cur, new_cur);
} else {
int j = 0;
while (cur[j].second != i)
++j;
cur.erase(cur.begin() + j);
cout << 0 << '\n';
cout << "IGNORE" << endl;
}
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3480kb
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: 3612kb
input:
1 1 100
output:
0 TAKE
result:
ok OK, worst = 1.000000 (1 test case)
Test #3:
score: -100
Wrong Answer
time: 7ms
memory: 3488kb
input:
2000 5 535 529 471 0 0 5 536 588 558 515 485 5 525 599 507 493 0 5 549 561 567 504 496 5 557 596 592 503 497 5 549 549 536 464 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 577 506 494 5 594 519 481 0 0 5 527 521 479 0 0 5 587 539 461 0 0 5 561...
output:
0 TAKE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 IGNORE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 IGNORE 0 IGNORE 0 TAKE 0 TAKE 0 TAKE 0 IG...
result:
wrong answer alg = 535 opt = 1000 (test case 1)