# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964263 | pcc | Akcija (COCI15_akcija) | C++17 | 14 ms | 1716 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;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 1e5+10;
int N;
deque<ll> dq;
ll ans = 0;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N;
for(int i = 0;i<N;i++){
ll k;
cin>>k;
dq.push_back(k);
}
sort(dq.begin(),dq.end());
ll ans = 0;
while(dq.size()>=3){
ans += dq.back();dq.pop_back();
ans += dq.back();dq.pop_back();
dq.pop_back();
}
while(!dq.empty()){
ans += dq.back();dq.pop_back();
}
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |