Submission #964263

#TimeUsernameProblemLanguageResultExecution timeMemory
964263pccAkcija (COCI15_akcija)C++17
80 / 80
14 ms1716 KiB
#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 timeMemoryGrader output
Fetching results...