forked from rajatgoyal715/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLisaWorkbook.java
More file actions
37 lines (34 loc) · 816 Bytes
/
LisaWorkbook.java
File metadata and controls
37 lines (34 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
33
34
35
36
37
package Implementation;
import java.util.Scanner;
/*
* @author -- rajatgoyal715
*/
public class LisaWorkbook {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int k=sc.nextInt();
int t[]=new int[n];
for(int i=0;i<n;i++){
t[i]=sc.nextInt();
}
int page=1;
int p,s,count=0;
for(int i=0;i<n;i++){
p=t[i]/k;
s=1;
while(p--!=0){
if(page>=s&&page<=s+k-1)
count++;
s+=k;
page++;
}
if(t[i]%k!=0){
if(page>=s&&page<=t[i])
count++;
page++;
}
}
System.out.println(count);
}
}