115262024-10-19 10:02:41MagyarKendeSZLGTakaros Sorozat (80 pont)cpp17Wrong answer 38/809ms2136 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N), na(N), po(N), sz(N);
    for (int i = 0; i < N; i++) {
        char c;
        cin >> c;
        na[i] = !(a[i] = c == '1');
    }

    partial_sum(a.begin(), a.end(), po.begin());
    partial_sum(na.rbegin(), na.rend(), sz.rbegin());

    int result = min(po.back(), sz.front());
    for (int i = 1; i < N - 1; i++) {
        result = min(result, po[i - 1] + sz[i]);
    }

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base38/80
1Wrong answer0/01ms320 KiB
2Wrong answer0/08ms2104 KiB
3Partially correct2/41ms404 KiB
4Partially correct2/41ms512 KiB
5Partially correct2/41ms560 KiB
6Partially correct2/41ms568 KiB
7Wrong answer0/41ms320 KiB
8Partially correct2/41ms408 KiB
9Partially correct2/41ms320 KiB
10Partially correct2/41ms320 KiB
11Partially correct2/41ms320 KiB
12Partially correct2/41ms408 KiB
13Partially correct2/48ms1952 KiB
14Partially correct2/48ms1968 KiB
15Partially correct2/48ms2084 KiB
16Partially correct2/48ms1960 KiB
17Partially correct2/48ms2040 KiB
18Partially correct2/49ms1848 KiB
19Partially correct2/48ms2036 KiB
20Partially correct2/48ms1848 KiB
21Partially correct2/48ms2136 KiB
22Partially correct2/48ms1952 KiB