Skip to content

Instantly share code, notes, and snippets.

@jinjor
Last active August 29, 2015 14:01
Show Gist options
  • Save jinjor/a58d032efbea93a4d1aa to your computer and use it in GitHub Desktop.
Save jinjor/a58d032efbea93a4d1aa to your computer and use it in GitHub Desktop.
CodeIQ「チケットゴブル問題」貪欲法 303bytes
import Data.List.Split;import Data.List;import Data.Ord;b(_,_,a)=a;p q[]=[];p q((n,w,a):t)|q<w=n:(p a t)|True=p q t;y a=(show.length)a++(a>>=id);main=do e<-readFile"tickets.txt";putStr.y.sort$p 0$sortBy(comparing b)[(' ':l!!0,w 1,w 3)|s<-lines e,let l=splitOneOf" -/"s;p=read.(!!)l;w i=31*(p i)+(p$i+1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment