# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1269274 | sohamsen15 | Akcija (COCI15_akcija) | C++20 | 11 ms | 1096 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll n, ans = 0; cin >> n;
vector<ll> a(n); for (auto &x: a) cin >> x;
sort(a.rbegin(), a.rend());
for (ll i = 0; i < n; i += 3) {
if (i + 2 < n) ans += a[i] + a[i + 1];
else if (i + 1 < n) ans += a[i] + a[i + 1];
else ans += a[i];
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |