/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 764.0 KiB
#2 Accepted 5ms 532.0 KiB
#3 Accepted 6ms 532.0 KiB
#4 Accepted 4ms 764.0 KiB
#5 Accepted 3ms 764.0 KiB
#6 Accepted 9ms 764.0 KiB
#7 Accepted 80ms 772.0 KiB
#8 Accepted 8ms 532.0 KiB
#9 Accepted 66ms 772.0 KiB
#10 Accepted 45ms 532.0 KiB

Code

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

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

    int32_t Case = 1;    cin >> Case;
    for (int T = 1; T <= Case; T++) {

        int n; cin >> n;
        int ar[n]; for(int & i : ar) cin >> i;
        sort(ar, ar + n);

        bitset<50001> dp;
        dp[0] = 1;
        for(int i = 0; i < n; i++) {
            if(ar[i] <= n) dp |= (dp << ar[i]);
        }

        int mx = 0;
        for(int i = n; i >= 0; i--) {
            if(dp[i]) {
                mx = i;
                break;
            }
        }
        cout << mx << '\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:39:02
Judged At
2026-01-06 16:39:02
Judged By
Score
100
Total Time
80ms
Peak Memory
772.0 KiB