70432023-12-28 20:26:25MagyarKendeSZLGKövek (100 pont)cpp17Runtime error 10/100104ms64852 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int result;

ll pc;

void solve(vector<int>& v) {
    if (v.size() == 1) return;

    sort(all(v));

    int l = 0, r = v.size() - 1;
    vector<int> rem;
    while (l < r) {
        int sum = v[l] + v[r];
        if (sum & 1) {
            rem.push_back(sum >> 1);
            rem.push_back((sum >> 1) + 1);
        }
        result++;
        l++;
        r--;
    }

    if (l == r) {
        rem.push_back(v[l]);
    }

    if (!rem.empty()) {
        solve(rem);
    }
}

int main() {
    speed;

    int N;
    cin >> N;
    vector<int> v(N);
    cinv(v);
    solve(v);

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base10/100
1Accepted0/03ms1824 KiB
2Runtime error0/096ms64852 KiB
3Wrong answer0/53ms2144 KiB
4Wrong answer0/53ms2212 KiB
5Wrong answer0/53ms2348 KiB
6Wrong answer0/53ms2556 KiB
7Accepted5/53ms2640 KiB
8Accepted5/53ms2776 KiB
9Wrong answer0/73ms2848 KiB
10Wrong answer0/73ms2844 KiB
11Wrong answer0/83ms2988 KiB
12Runtime error0/859ms63900 KiB
13Runtime error0/874ms63656 KiB
14Wrong answer0/84ms3628 KiB
15Runtime error0/898ms63424 KiB
16Runtime error0/893ms63392 KiB
17Runtime error0/8104ms63384 KiB