Accepted
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