CSES - Aalto Competitive Programming 2024 - wk12 Homework - Results
Submission details
Task:Missing Coin Sum
Sender:Nallue
Submission time:2024-11-23 15:56:42 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4--details
#5ACCEPTED0.10 sdetails
#6--details
#7--details
#8--details
#9ACCEPTED0.00 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

bool subsetExists(const vector<int>& vec, int final, int sum){
    if(sum == 0) return true;
    if(sum < 0) return false;
    if(final == 0) return false;

    return subsetExists(vec, final-1, sum) or subsetExists(vec, final-1, sum-vec[final-1]);
}


int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n; i++) cin >> vec[i];

    int idx=0;
    while(subsetExists(vec, n, idx)) idx += 1;

    cout<< idx << endl;


}

Test details

Test 1

Verdict: ACCEPTED

input
4
2 1 4 3

correct output
11

user output
11

Test 2

Verdict: ACCEPTED

input
4
2 2 2 2

correct output
1

user output
1

Test 3

Verdict: ACCEPTED

input
6
1 9 9 1 2 2

correct output
7

user output
7

Test 4

Verdict:

input
200000
38 62 12 96 82 18 48 47 22 3 6...

correct output
10114269

user output
(empty)

Test 5

Verdict: ACCEPTED

input
200000
321076699 332784673 745614086 ...

correct output
1

user output
1

Test 6

Verdict:

input
200000
1 136292223 60613622 935902310...

correct output
5069547

user output
(empty)

Test 7

Verdict:

input
60
1 2 4 8 16 32 64 128 256 512 1...

correct output
31073741824

user output
(empty)

Test 8

Verdict:

input
100000
1 2 4 8 16 32 64 128 256 512 1...

correct output
53672058814464

user output
(empty)

Test 9

Verdict: ACCEPTED

input
10
1 1 1 1 1 1 1 1 2 7

correct output
18

user output
18