京东笔试 编程题
考试复习计划的
# -*- 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)
#京东#