CSES - Aalto Competitive Programming 2024 - wk12 Homework - Results
Submission details
Task:Missing Coin Sum
Sender:Rasse
Submission time:2024-11-20 22:44:29 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.03 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.04 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.02 sdetails
#9ACCEPTED0.00 sdetails

Code

#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <climits>
#include <cmath>
#include <functional>
#include <type_traits>
#include <fstream>
#include <bitset>
#include <complex>
#include <iomanip>

#include <ext/pb_ds/assoc_container.hpp> // gcc only
template<typename T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
 
#define int long long
using namespace std;
 
#define cross(x, y) (((x)*conj(y)).imag())
#define sign(v) ((0 < (v)) - ((v) < 0))



int p(int a, int b, int m)
{
    if (b == 0) return 1;
    else if (b % 2 == 0) { int r = p(a, b/2, m); return (r*r) % m; }
    else return (p(a, b-1, m)*a) % m; 
}
int gdc(int a, int b)
{
    if (b == 0) return a;
    return gdc(b, a%b);
}
 
int nCr(int n, int r, int mod)
{
    int res = 1;
    for (int i = 0; i < r; i++)
    {
        res *= (n-i);
        res *= p(i+1, mod-2, mod);
    }
    return res;
}
int mod = 998244353;

void solve()
{
    int n;
    cin >> n;

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

    sort(nums.begin(), nums.end());
    if (nums[0] != 1)
    {
        cout << 1;
        return;
    }
    int big = 1;
    for (int i = 1; i < n; i++)
    {
        if (nums[i] > big+1)
        {
            cout << big+1;
            return;
        }
        big += nums[i];
    }
    cout << big+1;

}
 
 
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int t = 1;
 
    //cin >> t;
 
    for (int i = 0; i < t; i++)
    {
        solve();
        //cout.flush();
    }
}

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: ACCEPTED

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

correct output
10114269

user output
10114269

Test 5

Verdict: ACCEPTED

input
200000
321076699 332784673 745614086 ...

correct output
1

user output
1

Test 6

Verdict: ACCEPTED

input
200000
1 136292223 60613622 935902310...

correct output
5069547

user output
5069547

Test 7

Verdict: ACCEPTED

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

correct output
31073741824

user output
31073741824

Test 8

Verdict: ACCEPTED

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

correct output
53672058814464

user output
53672058814464

Test 9

Verdict: ACCEPTED

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

correct output
18

user output
18