Codeforces Beta Round #37 B. Computer Game
そのときに詠唱可能な最も強い呪文を唱える。NOとなるのは、ボスのHPが減らないかつ新たに唱える呪文が無い場合。ボスのHPが減らないだけだと↓の入力にNOを返してしまう。
3 100 29 100 10 100 10 100 10
import itertools N,max,reg = map(int,raw_input().split()) pow = [0]*N dmg = [0]*N for i in range(N): pow[i],dmg[i] = map(int,raw_input().split()) history = [] used = [False]*N HP = max for t in itertools.count(): prev = HP for i in range(N): if used[i]: HP -= dmg[i] HP = min(HP+reg,max) if HP<=0: print "YES" print t, len(history) for s in history: print s break s = -1 for i in range(N): if ( not used[i] and 100*HP<=max*pow[i] and ( s==-1 or dmg[i]>dmg[s] ) ): s = i if s!=-1: used[s] = True history += ["%d %d"%(t,s+1)] if HP==prev and s==-1: print "NO" break