Rezultati

Up. imeNalogaJezikRezultatČas oddaje
pspace-2017 Hodnik C++ 100/100OK 20. apr '17 @ 16:43

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,117 MiB 0,004 s OK
#2 10/10 3,113 MiB 0,004 s OK
#3 10/10 3,063 MiB 0,004 s OK
#4 10/10 3,117 MiB 0,004 s OK
#5 10/10 3,063 MiB 0,004 s OK
#6 10/10 3,133 MiB 0,004 s OK
#7 10/10 3,121 MiB 0,004 s OK
#8 10/10 3,125 MiB 0,004 s OK
#9 10/10 3,125 MiB 0,004 s OK
#10 10/10 3,133 MiB 0,004 s OK

Ocenjevani program (main.cpp):
#include <bits/stdc++.h>

using namespace std;


int main() {
    string s;
    cin >> s;
    int len = s.length();

    string s1, s2;

    int diff1 = 0, diff2 = 0;

    for(int i=0;i<len;i++) {
        s1 += '0' + (i+1)%2;
        s2 += '0' + i%2;

        if(s1[i] != s[i]) diff1++;
        if(s2[i] != s[i]) diff2++;
    }

    if(diff1 <= diff2) cout << diff1 <<endl;
    else cout <<diff2;

    return 0;
}