답안 #964263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964263 2024-04-16T13:52:28 Z pcc Akcija (COCI15_akcija) C++17
80 / 80
14 ms 1716 KB
#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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 11 ms 1628 KB Output is correct
7 Correct 7 ms 1492 KB Output is correct
8 Correct 7 ms 1628 KB Output is correct
9 Correct 14 ms 1716 KB Output is correct
10 Correct 14 ms 1628 KB Output is correct