-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFashionInBerland.java
More file actions
43 lines (36 loc) · 821 Bytes
/
FashionInBerland.java
File metadata and controls
43 lines (36 loc) · 821 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
37
38
39
40
41
42
43
/* https://codeforces.com/contest/691/problem/A
#implementation
count the number of 0 in the array.
special case: when only have an array with length 1.
*/
import java.util.Scanner;
public class FashionInBerland {
static String myFunction() {
Scanner obj = new Scanner(System.in);
int number = obj.nextInt();
// special case
if (number == 1) {
if (0 == obj.nextInt()) {
return "NO";
} else {
return "YES";
}
}
int countZero = 0;
for (int i = 0; i < number; i++) {
if (0 == obj.nextInt()) {
countZero++;
}
if (countZero > 1) {
break;
}
}
if (countZero != 1) {
return "NO";
}
return "YES";
}
public static void main(String argr[]) {
System.out.println(myFunction());
}
}