-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj_1439.java
More file actions
35 lines (28 loc) · 760 Bytes
/
boj_1439.java
File metadata and controls
35 lines (28 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package greedy;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class boj_1439 {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
char[] c=br.readLine().toCharArray();
int count0=0;
int count1=0;
if(c[0]=='0') {
count0++;
}
else{
count1++;
}
for(int i=1;i<c.length;i++){
if(c[i-1]!=c[i]){
if(c[i]=='0'){
count0++;
}else{
count1++;
}
}
}
System.out.println(Math.min(count0,count1));
}
}