Submission #1076848

#TimeUsernameProblemLanguageResultExecution timeMemory
1076848toast12Akcija (COCI15_akcija)C++14
56 / 80
24 ms1372 KiB
#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 timeMemoryGrader output
Fetching results...