#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n; cin>>n;
vector<int> c(n);
for (int i=0; i<n; i++) cin>>c[i];
sort(c.begin(),c.end(),greater<int>());
int ans=0;
for (auto i: c) ans+=i;
for (int i=2; i<n; i+=3){
ans-=c[i];
}
cout<<ans<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
16 ms |
1604 KB |
Output is correct |
7 |
Correct |
15 ms |
1372 KB |
Output is correct |
8 |
Correct |
13 ms |
1620 KB |
Output is correct |
9 |
Correct |
21 ms |
1628 KB |
Output is correct |
10 |
Correct |
21 ms |
1728 KB |
Output is correct |