Submission #858354

#TimeUsernameProblemLanguageResultExecution timeMemory
858354ily2003Akcija (COCI15_akcija)C++14
80 / 80
12 ms1372 KiB
#include <bits/stdc++.h> using namespace std; int n,tong,dem,a[100001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin >> n; for (int i=1;i<=n;++i) cin >> a[i]; sort(a+1,a+n+1); for (int i=1;i<=n%3;++i) tong+=a[i]; dem=2; for (int i=n%3+1;i<=n;++i) { ++dem; if (dem==3) { dem=0; continue; } tong+=a[i]; } cout << tong; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...