-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBsCost.java
More file actions
35 lines (29 loc) · 864 Bytes
/
Copy pathBsCost.java
File metadata and controls
35 lines (29 loc) · 864 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 io.github.tahanima.codechef;
import java.util.Scanner;
/**
* @author tahanima
*/
public class BsCost {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int cases = scanner.nextInt();
while (cases-- > 0) {
scanner.nextInt();
int min = Math.min(scanner.nextInt(), scanner.nextInt());
String binaryStr = scanner.next();
boolean hasZero = false;
boolean hasOne = false;
for (char ch: binaryStr.toCharArray()) {
if (ch == '0')
hasZero = true;
else
hasOne = true;
}
if (hasOne && hasZero) {
System.out.println(min);
} else {
System.out.println(0);
}
}
}
}