2012-09-23から1日間の記事一覧
Rubyの勉強がてらにCodeforcesの問題を解いてみた。http://www.codeforces.com/contest/222/problem/A def solve(k, a) t = a[k - 1] # kより後ろの配列 other = a[k - 1 .. -1] other.each do |i| if i != t return -1 end end c = 0 (k - 1).downto(0) do …
Rubyの勉強がてらにCodeforcesの問題を解いてみた。http://www.codeforces.com/contest/222/problem/A def solve(k, a) t = a[k - 1] # kより後ろの配列 other = a[k - 1 .. -1] other.each do |i| if i != t return -1 end end c = 0 (k - 1).downto(0) do …