Skip to content

Instantly share code, notes, and snippets.

@Wizmann
Created November 21, 2012 13:58
Show Gist options
  • Save Wizmann/4124979 to your computer and use it in GitHub Desktop.
Save Wizmann/4124979 to your computer and use it in GitHub Desktop.
Codeforces Round #149 (Div. 2) (B)
import java.util.Scanner
object Main extends App
{
val cin=new Scanner(System.in)
val n=cin.nextInt()
val seg=(1<<30,0) :: List.tabulate(n)(_=>(cin.nextInt,cin.nextInt))
val s=seg.reduce((a,b) => (math.min(a._1,b._1),math.max(a._2,b._2)))
println(seg.indexOf(s))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment