-
-
Save enzerr/4ec02488e3fc86ebdf81ee3e4cda4e78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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