# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076851 | toast12 | Akcija (COCI15_akcija) | C++14 | 25 ms | 840 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; i++) {
cin >> nums[i];
}
sort(nums.begin(), nums.end());
ll ans = 0;
for (int i = n-1; i > 0; i -= 3) {
ans += nums[i]+nums[i-1];
}
if (n % 3 == 1)
ans += nums[0];
else if (n % 3 == 2)
ans += nums[0]+nums[1];
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |