Submission #154267

#TimeUsernameProblemLanguageResultExecution timeMemory
154267radugheoAkcija (COCI15_akcija)C++14
80 / 80
61 ms1372 KiB
#include <bits/stdc++.h> using namespace std; int n, i, sum, v[100005]; int main(){ cin >> n; for (i=1; i<=n; i++){ cin >> v[i]; } sort (v, v + n + 1); for (i=n; i>=1; i--){ sum += v[i]; if (n%3 == 0){ if (i%3 == 1){ sum -= v[i]; } } else if (n%3 == 1){ if (i%3 == 2){ sum -= v[i]; } } else{ if (i%3 == 0){ sum -= v[i]; } } } cout << sum; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...