Untitled
unknown
c_cpp
2 years ago
499 B
9
Indexable
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin >> n;
int niza[n];
for(int i = 0; i < n; i++) {
cin >> niza[i];
}
sort(niza, niza + n);
int S = 0, E = n - 1;
int res = 0;
while(S < E) {
while(S < E and niza[S] > 0) {
niza[S]--;
E--;
res++;
}
S++;
}
cout << res << endl;
return 0;
}
Editor is loading...
Leave a Comment