-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathanotherbrick.java
More file actions
52 lines (41 loc) · 749 Bytes
/
Copy pathanotherbrick.java
File metadata and controls
52 lines (41 loc) · 749 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
44
45
46
47
48
49
50
51
52
import java.util.Scanner;
public class anotherbrick {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int height = scan.nextInt();
int width = scan.nextInt();
int bricks = scan.nextInt();
boolean build = true;
int[] nums = new int[bricks];
for (int i = 0; i < nums.length; i++)
nums[i] = scan.nextInt();
int brick = 0;
int wid = 0;
main: for (int high = 1; high <= height; high++)
{
wid = width;
while (wid > 0)
{
if (brick == nums.length)
{
build = false;
break main;
}
else
{
wid -= nums[brick];
}
brick++;
}
if (wid < 0)
{
build = false;
break main;
}
}
if (build)
System.out.println("YES");
else
System.out.println("NO");
}
}