# 【kickstart round F 2020】前两题 python 题解

from collections import deque
import math
T=int(input())
for tt in range(T):
N,X=[int(s) for s in input().split()]
withdraw=[int(s) for s in input().split()]
stack=[]
for i in range(N):
withdraw[i]=math.ceil(withdraw[i]/X)
for i in range(N):
stack.append([i,withdraw[i]])
stack.sort(key=lambda x:x[1])
order=[i[0] for i in stack]

print('Case #{}: '.format(tt+1),end='')
for i in range(N):
if i!=N-1:
print(order[i]+1,end=' ')
else:
print(order[i]+1)


import math
T=int(input())
for tt in range(T):
N,K=[int(s) for s in input().split()]
robot=[]
for nn in range(N):
s,e=[int(s) for s in input().split()]
robot.append([s,e])
robot.sort(key=lambda x:x[0])
ans=0
res=0
for p in robot:
if p[1]<=res:
continue
if p[0]>=res:
h=math.ceil((p[1]-p[0])/K)
ans+=h
res=p[0]+K*h
else:
h=math.ceil((p[1]-res)/K)
ans+=h
res+=K*h
print('Case #{}: {}'.format(tt+1,ans))

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

一杯敬月光

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

03-25 570
07-18 84