Skip to content

Instantly share code, notes, and snippets.

@enzerr
Created April 17, 2023 12:28
Show Gist options
  • Save enzerr/4ec02488e3fc86ebdf81ee3e4cda4e78 to your computer and use it in GitHub Desktop.
Save enzerr/4ec02488e3fc86ebdf81ee3e4cda4e78 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e5 + 5;
int v[maxn];
int32_t main(){
int n; cin >> n;
for(int i = 0; i < n; i++) cin >> v[i];
sort(v, v+n);
int ans=1;
for(int i = 0; i < n; i++){
if(v[i]>ans) break;
else ans += v[i];
}
cout << ans << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment