#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
ll ans = 0;
vector<int> nums(n);
for (int i = 0; i < n; i++) {
cin >> nums[i];
ans += nums[i];
}
sort(nums.begin(), nums.end());
reverse(nums.begin(), nums.end());
for (int i = 0; i < n; i++) {
if (i % 3 == 2)
ans -= nums[i];
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 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 |
17 ms |
1208 KB |
Output is correct |
7 |
Correct |
14 ms |
1116 KB |
Output is correct |
8 |
Correct |
21 ms |
1204 KB |
Output is correct |
9 |
Correct |
23 ms |
1392 KB |
Output is correct |
10 |
Correct |
22 ms |
1368 KB |
Output is correct |