AtCoder

キーエンス プログラミング コンテスト 2020

https://atcoder.jp/contests/keyence2020 過去問。 A h, w, n = readlines.map(&:to_i) puts (n / [h, w].max.to_f).ceil B imos法かと思ったが、ちがっていた。 n = gets.to_i data = n.times.map {gets.split.map(&:to_i)}.map {|x, l| [x - l, x + l]} r…

ABC151

https://atcoder.jp/contests/abc151 過去問。 A puts gets.chomp.succ B n, k, m = gets.split.map(&:to_i) sum = gets.split.map(&:to_i).inject(&:+) target = m * n - sum result = case when target < 0 then 0 when target > k then -1 else target en…

ABC152

https://atcoder.jp/contests/abc152 過去問。 A n, m = gets.split.map(&:to_i) puts (n == m) ? "Yes" : "No" B a, b = gets.split.map(&:to_i) result = a.to_s * b tmp = b.to_s * a result = tmp if result > tmp puts result C これはすぐに思いついた…

AtCoder/ABC138

A - Red or Not puts (gets.to_i >= 3200) ? gets.chomp : "red" B - Resistors in Parallel gets as = gets.split.map(&:to_i) puts Rational(1, as.map {|i| Rational(1, i)}.inject(:+)).to_f C - Alchemist gets as = gets.split.map(&:to_i).sort def c…

AtCoder/ABC137

A - +-x a, b = gets.split.map(&:to_i) puts [a + b, a - b, a * b].max B - One Clue k, x = gets.split.map(&:to_i) puts [*x - k + 1..x + k - 1].join(" ") C - Green Bin words = gets.to_i.times.map {gets.chomp.chars.sort.join}.group_by(&:itself…

AtCorder/ABC(その1)

ABC001 A - 積雪深差 puts gets.to_i - gets.to_i B - 視程の通報 ans = case (m = gets.to_i) when 0...100 then 0 when 100..5000 then m / 100 when 6000..30000 then m / 1000 + 50 when 35000..70000 then (m / 1000 - 30) / 5 + 80 else 89 end puts s…

CPSCO2019 Session4

CPSCO2019 Session4 - AtCoder A - Swimming l, x = gets.split.map(&:to_i) n = x / l puts n.even? ? x % l : (n + 1) * l - x B - Meeting n, d = gets.split.map(&:to_i) table = d.times.map do gets.chomp.chars.map.with_index {|st, i| i if st == "…

AtCoder(AtCoder Beginners Selection)

AtCoder Beginners Selection - AtCoder PracticeA - はじめてのあっとこーだー(Welcome to AtCoder) a = gets.to_i b, c = gets.split.map(&:to_i) s = gets print "#{a + b + c} #{s}" ABC086A - Product a, b = gets.split.map(&:to_i) puts (a * b).od…