Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
paizaのアレをRubyのワンライナーで解いてみた
# 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