Skip to content

Instantly share code, notes, and snippets.

@einblicker
Created July 15, 2012 04:07
Show Gist options
  • Save einblicker/3114925 to your computer and use it in GitHub Desktop.
Save einblicker/3114925 to your computer and use it in GitHub Desktop.
AOJ 0033 Balls
let lineSize = System.Console.ReadLine() |> int
for x = 0 to lineSize - 1 do
let nums = System.Console.ReadLine().Split([|' '|]) |> Array.map int
let suc = ref false
let rec dfs i bMax cMax =
if i < nums.Length - 1 then
if nums.[i] > bMax then
dfs (i+1) nums.[i] cMax
if nums.[i] > cMax then
dfs (i+1) bMax nums.[i]
else
suc := true
dfs 2 nums.[0] nums.[1]
printfn "%A" (if !suc then "YES" else "NO")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment