Created
January 5, 2015 09:47
-
-
Save nullkal/0b23ed80ebcb1319d83e to your computer and use it in GitHub Desktop.
paizaのアレをRubyのワンライナーで解いてみた
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 01 | |
p $<.drop(1).map(&:to_i).inject(&:+) | |
# 02 | |
p $<.drop(1).inject(0){|m,n|t,s,p=n.split.map(&:to_i);m+=p.*t>s ?t-s :0} | |
# 03 | |
t,m,*p=gets.to_i,c=0;$<.each{|n|c+=l=n.to_i;p<<l;p.size<t||(m>c||m=c)&&c-=p.shift};p m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment