-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLisasWorkbook.java
More file actions
32 lines (30 loc) · 816 Bytes
/
LisasWorkbook.java
File metadata and controls
32 lines (30 loc) · 816 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
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int chap = scanner.nextInt();
int prob = scanner.nextInt();
int s = 0;
int pages = 0;
for(int i=0;i<chap;i++){
int chpProb = scanner.nextInt();
int pgNo = pages+1;
int count = 0;
for(int j=1;j<=chpProb;j++){
if(j==pgNo)
s++;
if(j%prob==0 && j<chpProb){
pgNo++;
}
}
pages=pgNo;
}
System.out.println(s);
}
}