71432023-12-31 13:10:15xxxTakaros Sorozat (80 pont)cpp17Wrong answer 40/804ms6952 KiB
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) {
        a[i] = s[i-1]-'0';
    }

    vector<int> frt(n+1), bw(n+2);

    for(int i = 1; i <= n; i++) {
        frt[i] = frt[i-1] + a[i];
        //cout << frt[i] << " ";
    }

    for(int i = n; i > 0; i--) {
        bw[i] = bw[i+1] + !a[i];

    }




    int ans1 = INT_MAX;

    for(int i = 0; i <= n; i++) {
        ans1 = min(ans1, frt[i] + bw[i+1]);
    }

    cout << ans1 << endl;


}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int tt=1;
	//cin >> tt;
	while(tt--) {
        solve();
	}


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/80
1Wrong answer0/03ms1828 KiB
2Wrong answer0/04ms4824 KiB
3Partially correct2/43ms2264 KiB
4Partially correct2/43ms2312 KiB
5Partially correct2/43ms2444 KiB
6Partially correct2/43ms2668 KiB
7Partially correct2/43ms2868 KiB
8Partially correct2/43ms3228 KiB
9Partially correct2/43ms3348 KiB
10Partially correct2/43ms3528 KiB
11Partially correct2/43ms3624 KiB
12Partially correct2/43ms3688 KiB
13Partially correct2/44ms5972 KiB
14Partially correct2/44ms5968 KiB
15Partially correct2/44ms6364 KiB
16Partially correct2/44ms6160 KiB
17Partially correct2/44ms6288 KiB
18Partially correct2/44ms6768 KiB
19Partially correct2/44ms6456 KiB
20Partially correct2/44ms6848 KiB
21Partially correct2/44ms6588 KiB
22Partially correct2/44ms6952 KiB