We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7498c5c commit b59a1f7Copy full SHA for b59a1f7
1 file changed
정건우/10주차/260303.java
@@ -0,0 +1,32 @@
1
+//https://www.acmicpc.net/problem/20365
2
+import java.io.BufferedReader;
3
+import java.io.IOException;
4
+import java.io.InputStreamReader;
5
+
6
+public class BOJ_S3_20365_블로그2 {
7
+ public static void main(String[] args) throws IOException {
8
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9
10
+ int N = Integer.parseInt(br.readLine());
11
+ String str = br.readLine();
12
13
+ int red = 0;
14
+ int blue = 0;
15
+ char past = ' ';
16
17
+ for (int i = 0; i < N; i++) {
18
+ char c = str.charAt(i);
19
20
+ if(c != past) {
21
+ if(c == 'R') red++;
22
+ else blue++;
23
24
+ past = c;
25
+ }
26
27
28
+ if(red == 0 || blue == 0) System.out.println(Math.max(red, blue));
29
+ else System.out.println(Math.min(red, blue)+1);
30
31
32
+}
0 commit comments