Submission #42719

#TimeUsernameProblemLanguageResultExecution timeMemory
42719theknife2001Akcija (COCI15_akcija)C++14
80 / 80
42 ms3388 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e5+55; int a[N]; int main() { int n; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); long long ans=0; for(int i=n-1;i>=0;i--) { if(i>=2) { ans+=a[i]; i--; ans+=a[i]; i--; } else ans+=a[i]; } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...