#include <iostream>
#include <algorithm>
using namespace std;
int n,v[100010],sum,of;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>v[i];
sum+=v[i];
}
sort(v+1,v+1+n,greater<>());
for(int i=1;of<n/3;i+=3){
sum-=min(min(v[i],v[i+1]),v[i+2]);
of++;
}
cout<<sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
48 ms |
1272 KB |
Output is correct |
7 |
Correct |
41 ms |
1016 KB |
Output is correct |
8 |
Correct |
42 ms |
1144 KB |
Output is correct |
9 |
Correct |
60 ms |
1272 KB |
Output is correct |
10 |
Correct |
60 ms |
1272 KB |
Output is correct |