Created
April 17, 2017 01:08
-
-
Save whatalnk/c1ca929e4fd019a337e533d6fcd4921e to your computer and use it in GitHub Desktop.
AtCoder ABC #017 [Ruby]
This file contains 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
res = 0 | |
while line = gets | |
e, s = line.chomp.split(" ").map(&:to_i) | |
res += e * s | |
end | |
puts res / 10 |
This file contains 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
str = gets.chomp | |
res = str.gsub(/ch/, "").gsub(/o/, "").gsub(/k/, "").gsub(/u/, "") | |
if res == "" then | |
puts "YES" | |
else | |
puts "NO" | |
end |
This file contains 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
# TLE, 100 | |
n, m = gets.chomp.split(" ").map(&:to_i) | |
ll = [] | |
rr = [] | |
ss = [] | |
n.times do | |
l, r, s = gets.chomp.split(" ").map(&:to_i) | |
ll << l | |
rr << r | |
ss << s | |
end | |
ret = 0 | |
m.times do |i| | |
score = 0 | |
g = i + 1 | |
n.times do |j| | |
if g >= ll[j] && g <= rr[j] then | |
next | |
else | |
score += ss[j] | |
end | |
end | |
ret = [ret, score].max | |
end | |
puts ret |
This file contains 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
# AC 101 | |
n, m = gets.chomp.split(" ").map(&:to_i) | |
a = Array.new(m+2, 0) | |
sum = 0 | |
n.times do | |
l, r, s = gets.chomp.split(" ").map(&:to_i) | |
a[l] += s | |
a[r+1] -= s | |
sum += s | |
end | |
(1..m).each do |i| | |
a[i+1] += a[i] | |
end | |
puts sum - a[1..m].min |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment