Submission #145988

#TimeUsernameProblemLanguageResultExecution timeMemory
145988grobarAkcija (COCI15_akcija)C++14
56 / 80
58 ms1272 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[n]; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); int mod=n%3; int sum=0; for(int i=(n-1);i>0;i=i-3) { sum=sum+a[i]+a[i-1]; } for(int i=0;i<mod;i++) { sum=sum+a[i]; } cout<<sum<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...