/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Accepted 6ms 532.0 KiB
#3 Accepted 9ms 576.0 KiB
#4 Accepted 9ms 532.0 KiB
#5 Accepted 8ms 532.0 KiB
#6 Accepted 9ms 532.0 KiB
#7 Accepted 75ms 960.0 KiB
#8 Accepted 9ms 324.0 KiB
#9 Accepted 63ms 788.0 KiB
#10 Accepted 39ms 788.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define debug(a) cerr << #a << " = " << (a) << nl;
#define ll long long
#define int long long
#define nl '\n'

const int N = 5e4+5;
bitset<N> dp;
void jAVA()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    dp.reset();
    dp[0] = 1;
    for(auto i: a) dp |= dp<<i;
    int ans = 0;
    for(int i=1;i<=n;++i) {
        if(dp[i]) ans = i;
    }
    cout << ans << nl;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int t = 1, cs = 0;
    cin >> t;
    while (t--){
        // cout << "Case " << ++cs << ": ";
        jAVA();
    }
    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 15:48:11
Judged At
2026-01-06 15:48:12
Judged By
Score
100
Total Time
75ms
Peak Memory
960.0 KiB