#include<iostream>
#include<algorithm>
using namespace std;
int N, arr[1000005];
long long sum = 0;
int main(){
cin >> N;
for( int i = 1; i <= N; i++ )
cin >> arr[i];
sort( arr + 1, arr + N + 1 );
for( int i = N; i >= 1; i -= 3 ){
sum += arr[i] + arr[i - 1];
}
cout << sum << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
376 KB |
Output is correct |
6 |
Correct |
44 ms |
1092 KB |
Output is correct |
7 |
Correct |
41 ms |
1144 KB |
Output is correct |
8 |
Correct |
41 ms |
1144 KB |
Output is correct |
9 |
Correct |
59 ms |
1248 KB |
Output is correct |
10 |
Correct |
59 ms |
1456 KB |
Output is correct |