#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
sort(a.begin(), a.end());
ll sum = 0;
for (int i = n-1; i >= 0; --i) {
if ((n-i) % 3) sum += a[i];
}
cout << sum << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
20 ms |
1200 KB |
Output is correct |
7 |
Correct |
19 ms |
1116 KB |
Output is correct |
8 |
Correct |
16 ms |
1208 KB |
Output is correct |
9 |
Correct |
25 ms |
1372 KB |
Output is correct |
10 |
Correct |
25 ms |
1388 KB |
Output is correct |