第二题粉碎50% 超时。。。。感觉复杂度不高啊
#!/usr/bin/env python
# encoding: utf-8
import sys
import math
n, h, k = map(int, sys.stdin.readline().strip().split(' '))
a = []
for i in range(n):
tmp = int(sys.stdin.readline().strip())
a.append(tmp)
total_time = 0
tmp = a.pop(0)
rem = h - tmp
is_empty = False
Flag = True
while a:
Flag = False
# print a
tmp = a.pop(0)
while rem >= tmp:
rem = rem - tmp
if a:
tmp = a.pop(0)
else:
is_empty = True
break
if is_empty:
total_time += int(math.ceil((h-rem)*1./k))
else:
tmp_time = int(math.ceil((tmp - rem)*1. / k))
# print rem, tmp
# print tmp_time
# break
rem = min(tmp_time * k + rem, h)
total_time += tmp_time
a = [tmp] + a
if Flag:
total_time = int(math.ceil(tmp*1./k))
print total_time