Untitled
unknown
plain_text
a year ago
401 B
8
Indexable
// y.ha
#include <bits/stdc++.h>
#define cook '\n'
using namespace std;
int n,a[1009] ;
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(nullptr) ;
cin >> n;
for ( int i = 1; i <= n; i++ ) cin >> a[i] ;
sort(a+1,a+1+n);
int need = 1;
for ( int i = 1; i <= n; i++ )
if ( a[i] <= need ) need+= a[i] ;
else break ;
cout << need;
}
Editor is loading...
Leave a Comment