Codeforces #37 B "Computer Game"

問題:http://codeforces.com/contest/37/problem/B

ラクティス.

呪文書の能力と敵ボスの最大HPと再生による回復値が与えられる.
各呪文書は一回ずつしか使えないし,現在のHPがボスの最大HP×スクロールのパワーの割合を超えてないと使えない.使った呪文書は毎ターンダメージを与え,累積される.フェーズとしては1.ボスがダメージを喰らう.2.再生によってHP回復.3.ボスの死亡判定.4.主人公による呪文書の決定.となる.(ここらへんでいろいろ揉めてたみたい)ボスを倒せるかどうか,倒せるなら呪文書を使う時間とその番号を答える.

コピペ.各時間でシミュレーションしてるみたい.本番では英語がさっぱり読めなかった.

import java.io.*;
import java.util.*;


public class B_ComputerGame {
	// copy
	public static void main(String[] args) throws Exception{
		Scanner s = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = s.nextInt(), max = s.nextInt(), reg = s.nextInt();// 1-1000
		int[][] scrolls = new int[n][3];
		for (int i = 0; i < n; ++i) {
			int pow = s.nextInt(), dmg = s.nextInt(); // 0-100, 1-2000
			scrolls[i][0]=i;
			scrolls[i][1]=pow;
			scrolls[i][2]=dmg;
		}
		int hp = max;
		int dmg = 0;
		boolean[] used = new boolean[n];
		List<int[]> history = new ArrayList<int[]>();
		String result="NO";
		int t = 0;
		for(; t < 10001; ++t){
			hp -= dmg;
			hp = Math.min(max, hp + reg);
			if(hp <= 0){
				result = "YES";
				break;
			}
			int[] selectScroll = {-1,-1,-1};
			for(int[] scroll : scrolls){
				if(!used[scroll[0]] && selectScroll[2] < scroll[2] && scroll[1] * max >= hp * 100){
					selectScroll = scroll;
				}
			}
			if(selectScroll[0] >= 0){
				used[selectScroll[0]]=true;
				history.add(new int[]{t, selectScroll[0]+1});
				dmg += selectScroll[2];
			}
		}
		pw.println(result);
		if(result.equals("YES")){
			pw.println(t+" "+history.size());
			for(int[] is : history){
				pw.println(is[0] +" " + is[1]);
			}
		}
		pw.close();
	}
}