# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
541984 | Olympia | Akcija (COCI15_akcija) | C++17 | 16 ms | 1660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <limits.h>
#include <queue>
using namespace std;
int main() {
//freopen("inp.txt", "r", stdin);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vector<int> v(N); for (int i = 0; i < N; i++) cin >> v[i];
sort(v.begin(), v.end());
deque<int> d;
for (int i: v) {
d.push_back(i);
}
int64_t ans = 0;
while (!d.empty()) {
if (d.size() <= 2) {
while (!d.empty()) {
ans += d.back(), d.pop_back();
}
break;
}
ans += d.back();
//cout << "GET " << d.back() << '\n';
d.pop_back();
ans += d.back();
//cout << "GET " << d.back() << '\n';
d.pop_back();
d.pop_back();
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |