# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076848 | toast12 | Akcija (COCI15_akcija) | C++14 | 24 ms | 1372 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;
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());
int 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... |