#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n; cin >> n;
vector<int> a(n);
for (int &i : a) {
cin >> i;
}
sort(a.rbegin(), a.rend());
long long r = 0;
for (int i = 0; i < n; i++) {
if (i % 3 != 2) {
r += a[i];
}
}
cout << r << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
15 ms |
1132 KB |
Output is correct |
7 |
Correct |
10 ms |
1132 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1260 KB |
Output is correct |
10 |
Correct |
19 ms |
1260 KB |
Output is correct |