-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathA_Small.java
More file actions
36 lines (30 loc) · 732 Bytes
/
A_Small.java
File metadata and controls
36 lines (30 loc) · 732 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
36
/*
* Author: Minho Kim (ISKU)
* Date: 2017.04.12
* E-mail: minho1a@hanmail.net
*
* https://github.com/ISKU/Algorithm
* https://code.google.com/codejam/contest/6224486/dashboard#s=p0
*/
import java.util.Scanner;
public class A_Small {
public static void main(String... args) {
Scanner input = new Scanner(System.in);
int testCase = input.nextInt();
for (int tCase = 1; tCase <= testCase; tCase++) {
input.nextInt();
char[] S = input.next().toCharArray();
int ans = 0;
int sum = 0;
for (int i = 0; i < S.length; ++i) {
int num = S[i] - '0';
if (num > 0 && sum < i) {
ans += i - sum;
sum = i;
}
sum += num;
}
System.out.printf("Case #%d: %d\n", tCase, ans);
}
}
}