forked from srgnk/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlisa-workbook.py
More file actions
32 lines (25 loc) · 798 Bytes
/
lisa-workbook.py
File metadata and controls
32 lines (25 loc) · 798 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
#!/bin/python3
import sys
from math import ceil
def workbook(n, k, arr):
res = 0
page = 1
for el in arr:
pr_cur = 1
for pr in range(pr_cur, pr_cur + el):
if pr == page + pr//k - (1 if pr%k == 0 else 0):
res += 1
#print("problem = {} page = {} page% = {} res = {}".format(pr, page + pr//k - (1 if pr%k == 0 else 0), pr%k, res))
#print()
if el%k == 0:
page += el//k
else:
page += 1 + el//k
#print("page at end: {}".format(page))
return res
if __name__ == "__main__":
n, k = input().strip().split(' ')
n, k = [int(n), int(k)]
arr = list(map(int, input().strip().split(' ')))
result = workbook(n, k, arr)
print(result)