import java.util.Scanner object Problem231 { def proc(n: Int, gd: List[(Int, Int)]): List[String] = { val needExp = 3000000 val lostExpByDeath = needExp / 100 val z = gd.zip(Stream from 1) val canLevelUpDungeon = z.filter(x => x._1._1 >= x._1._2 * lostExpByDeath) if (canLevelUpDungeon.isEmpty) { return List("NO") } val mostEffectiveDungeon = canLevelUpDungeon.maxBy(x => x._1._1 - x._1._2 * lostExpByDeath) val mostEffectiveDungeonExp = mostEffectiveDungeon._1._1 - mostEffectiveDungeon._1._2 * lostExpByDeath val canLevelUpIn6Hours = mostEffectiveDungeonExp * 6 >= needExp if (canLevelUpIn6Hours) { "YES" :: List.fill(6)(mostEffectiveDungeon._2.toString) } else { List("NO") } } def main(args: Array[String]) { val sc = new Scanner(System.in) val n = sc.nextInt() val gd = List.fill(n)((sc.nextInt, sc.nextInt)) val results = proc(n, gd) results foreach { println(_) } } }