Accepted
Code
#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SUBLIME
freopen("inputf.in", "r", stdin);
freopen("outputf.out", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
int tt;
cin >> tt;
bitset <N> bs;
while (tt--) {
int n;
cin >> n;
bs.reset();
bs[0] = 1;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x > n) continue;
bs |= (bs << x);
}
int ans = 0;
for (int i = n; i >= 0; i--) {
if (bs[i]) {
ans = i;
break;
}
}
cout << ans << "\n";
}
return 0;
}
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:09:47
- Judged At
- 2026-01-06 16:09:47
- Judged By
- Score
- 100
- Total Time
- 85ms
- Peak Memory
- 576.0 KiB