Skip to content

Commit

Permalink
Adding CSES solution
Browse files Browse the repository at this point in the history
  • Loading branch information
AK-I-RA committed Jan 18, 2021
1 parent dab5575 commit 8ea0548
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CSES/Missing Coin Sum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include<bits/stdc++.h>
#include<iostream>
using namespace std;


#define pp pair<ll,ll>
#define all(x) (x).begin(), (x).end()
typedef long long int ll;

const int mxn = 2e5+10;

ll b[mxn];
ll a[mxn];

void subMain(){
ll n;
cin >> n;
for(ll i = 0; i < n; i++){
cin >> a[i];
}
sort(a, a+n);
ll cnt = 1;
for(ll i = 0; i < n && a[i] <= cnt; i++){
cnt += a[i];
}
cout << cnt << "\n";
}

int32_t main(){

ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);


/*ll t;
cin >> t;
while(t--){
subMain();
}*/
subMain();
}

0 comments on commit 8ea0548

Please sign in to comment.