Submission #1269274

#TimeUsernameProblemLanguageResultExecution timeMemory
1269274sohamsen15Akcija (COCI15_akcija)C++20
80 / 80
11 ms1096 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 timeMemoryGrader output
Fetching results...