forked from VipWangQiaoqiao/leetcode-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path听谁说笔试
37 lines (24 loc) · 753 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
捡贝壳
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int variety = scanner.nextInt();
int volume = scanner.nextInt();
int[] nums = new int[variety];
int[] vos = new int[variety];
for (int i = 0; i < variety; i++) {
nums[i] = scanner.nextInt();
vos[i] = scanner.nextInt();
}
int currentv = 0;
int count = 0;
for (int j = 0; j < variety; j++) {
for (int n = 0; n < nums[j]; n++) {
int t = vos[j] + currentv;
if (t > volume) break;
currentv = t;
count++;
}
}
System.out.println(count);
}
}