70422023-12-28 20:25:16MagyarKendeSZLGKövek (100 pont)cpp17Runtime error 10/10064ms64932 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(const vector<int>& v) {
    if (v.size() == 1) return;
    
    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);
    sort(all(v));
    solve(v);

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base10/100
1Accepted0/03ms1956 KiB
2Runtime error0/054ms64932 KiB
3Wrong answer0/53ms2176 KiB
4Wrong answer0/53ms2396 KiB
5Wrong answer0/53ms2620 KiB
6Wrong answer0/53ms2964 KiB
7Accepted5/53ms2940 KiB
8Accepted5/53ms3020 KiB
9Wrong answer0/73ms3092 KiB
10Wrong answer0/73ms3088 KiB
11Wrong answer0/83ms3088 KiB
12Runtime error0/859ms63664 KiB
13Runtime error0/863ms63640 KiB
14Wrong answer0/84ms3388 KiB
15Runtime error0/856ms63620 KiB
16Runtime error0/864ms63608 KiB
17Runtime error0/863ms63576 KiB