# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
462599 |
2021-08-10T22:11:04 Z |
JasperL |
Akcija (COCI15_akcija) |
C++14 |
|
38 ms |
1628 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define maxn 100005
typedef long long ll;
int n;
ll c[maxn], ret;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> c[i];
sort(c,c+n);
if (n%3 == 0) {
for (int i = 0; i < n; i += 3) ret += (c[i+1]+c[i+2]);
}
if (n%3 == 1) {
ret = c[0];
for (int i = 1; i < n; i += 3) ret += (c[i+1]+c[i+2]);
}
if (n%3 == 2) {
ret = c[0] + c[1];
for (int i = 2; i < n; i += 3) ret += (c[i+1]+c[i+2]);
}
cout << ret << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
36 ms |
1400 KB |
Output is correct |
7 |
Correct |
27 ms |
1444 KB |
Output is correct |
8 |
Correct |
26 ms |
1464 KB |
Output is correct |
9 |
Correct |
37 ms |
1592 KB |
Output is correct |
10 |
Correct |
38 ms |
1628 KB |
Output is correct |