# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
462599 | JasperL | Akcija (COCI15_akcija) | C++14 | 38 ms | 1628 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |