#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)5e5 + 7;
const int infint = (int)1e9;
const ll inf = (ll)1e18;
int n, a[MAXN];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
ll sm = 0, t = 0;
for (int i = 0; i < n; i++)
{
sm += a[i];
if(i % 3 == 0 && i + 2 < n)
t += a[i];
}
cout << sm - t;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
400 KB |
Output isn't correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
624 KB |
Output is correct |
6 |
Correct |
16 ms |
1444 KB |
Output is correct |
7 |
Correct |
14 ms |
2032 KB |
Output is correct |
8 |
Correct |
12 ms |
2444 KB |
Output is correct |
9 |
Incorrect |
21 ms |
2864 KB |
Output isn't correct |
10 |
Incorrect |
20 ms |
3436 KB |
Output isn't correct |