# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42719 | theknife2001 | Akcija (COCI15_akcija) | C++14 | 42 ms | 3388 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |