반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <iostream>
#include <algorithm>
using namespace std;
int cnt0, cnt1;
int main() {
string str;
cin >> str;
char cur = str[0];
if (cur == '0')
cnt0++;
else
cnt1++;
for (char c : str) {
if (cur != c) {
if (c == '0')
cnt0++;
else
cnt1++;
cur = c;
}
}
cout << min(cnt0, cnt1);
}
|
cs |
반응형