Submission #462599

#TimeUsernameProblemLanguageResultExecution timeMemory
462599JasperLAkcija (COCI15_akcija)C++14
80 / 80
38 ms1628 KiB
#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 timeMemoryGrader output
Fetching results...