/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 576.0 KiB
#2 Accepted 6ms 580.0 KiB
#3 Accepted 8ms 532.0 KiB
#4 Accepted 6ms 532.0 KiB
#5 Accepted 4ms 536.0 KiB
#6 Accepted 26ms 532.0 KiB
#7 Accepted 78ms 788.0 KiB
#8 Accepted 8ms 536.0 KiB
#9 Accepted 60ms 836.0 KiB
#10 Accepted 37ms 788.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);

  int Q; cin >> Q;

  while (Q--) [&] {
    int n; cin >> n;

    vector<int> a;
    for (int i = 0; i < n; ++i) {
      int x; cin >> x;
      if (x > n) continue;
      a.push_back(x);
    }

    if (a.empty()) {
      cout << "0\n";
      return;
    }

    bitset<50005> dp;
    dp[0] = 1; 

    for (int x : a) {
      dp |= (dp << x);
    }

    for (int i = n; i >= 0; i--) {
      if (dp[i]) {
        cout << i << "\n";
        return;
      }
    }
  }();
}

Information

Submit By
Type
Submission
Problem
P1234 E. Roy and Maximum Removals
Contest
Happy New Year 2026
Language
C++17 (G++ 13.2.0)
Submit At
2026-01-06 16:23:49
Judged At
2026-01-06 16:23:49
Judged By
Score
100
Total Time
78ms
Peak Memory
836.0 KiB