京东笔试 编程题

考试复习计划的
# -*- 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

相关推荐

10-05 11:11
海南大学 Java
投票
理想江南137:感觉挺真诚的 感觉可以试一试
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务