Task: | Missing Coin Sum |
Sender: | bubu2006 |
Submission time: | 2024-11-22 23:13:30 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.04 s | details |
#5 | ACCEPTED | 0.05 s | details |
#6 | ACCEPTED | 0.04 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.02 s | details |
#9 | ACCEPTED | 0.00 s | details |
Code
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef long double ld; signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); // RTE if input wrong datatype int n; cin>>n; vi x(n); for(int& a:x)cin>>a; sort(all(x)); int res=1; for(int a:x){ if(a>res){ cout<<res; return 0; } res+=a; } cout<<res; }
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 |