京东笔试 编程题

考试复习计划的
# -*- coding:utf-8 -*-
while True:
	n,sumtime = raw_input().split(" ")
	n = int(n)
	sumtime = int(sumtime)
	minls = []
	maxls = []
	while n:

		imin,imax = raw_input().split(" ")
		minls.append( int(imin) )
		maxls.append(int(imax))
		n-=1
	if sum(maxls)< sumtime:
		print "No"
	elif sum(minls)>sumtime:
		print "No"
	else:
		print "Yes"
		leve = sumtime-sum(minls)

		for i in range(len(minls)):
			if leve ==0:
				break
			if leve>= (maxls[i]-minls[i]):
				leve -= maxls[i]-minls[i]
				minls[i] =maxls[i]
			else:
				minls[i] += leve
				leve = 0
		result = ""
		for h in minls:
			result = result+str(h)+" "
		print result 


***游戏
# -*- coding:utf-8 -*-
while True:
	n = int (raw_input())
	lss = raw_input().split(" ")
	m = int(lss[0])
	lss = lss[1:]
	ls = [int(i) for i in lss]
	sortls = sorted(ls)
	cur =m
	if n == 1:
		print  0

	while True:
		if cur > sortls[-1]:
			break
		cur+=1
		sortls[-1] -=1
		sortls = sorted(sortls)
	print str(cur-m) 


#京东#
全部评论
能通过吗
点赞 回复 分享
发布于 2016-04-08 21:31

相关推荐

点赞 评论 收藏
分享
掩卷思:这简历做的感觉好简陋啊,找个模板呗
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务