QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#516947#9178. All-You-Can-Eatucup-team1198#WA 11ms3820kbC++201.9kb2024-08-13 00:54:402024-08-13 00:54:40

Judging History

你现在查看的是最新测评结果

  • [2024-08-13 00:54:40]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3820kb
  • [2024-08-13 00:54:40]
  • 提交

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;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    cur.emplace_back(x, i);
    int cur_sum = 0;
    for (auto [y, j] : cur)
      cur_sum += y;

    //cerr << "SUM: " << cur_sum << '\n';

    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: 1ms
memory: 3820kb

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: 3752kb

input:

1
1
100

output:

0
TAKE

result:

ok OK, worst = 1.000000 (1 test case)

Test #3:

score: -100
Wrong Answer
time: 11ms
memory: 3532kb

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)