Created
September 2, 2017 14:18
-
-
Save whatalnk/6f26d360c40f0522b9260f6e09231360 to your computer and use it in GitHub Desktop.
AtCoder ARC #082 / ABC #072
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
a, b = gets.chomp.split(" ").map(&:to_i) | |
puts [0, a - b].max |
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
s = gets.chomp.split("") | |
n = s.length | |
ret = [] | |
n.times do |i| | |
if (i + 1).odd? | |
ret << s[i] | |
end | |
end | |
puts ret.join("") |
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
n = gets.chomp.to_i | |
a = gets.chomp.split(" ").map(&:to_i) | |
b = Array.new(10**5+1, 0) | |
a.each do |i| | |
b[i] += 1 | |
end | |
ret = 0 | |
b.each_cons(3) do |v1, v2, v3| | |
ret = [ret, v1 + v2 + v3].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
n = gets.chomp.to_i | |
a = gets.chomp.split(" ").map(&:to_i) | |
ret = 0 | |
curr = 1 | |
i = 0 | |
loop do | |
break if i > n - 1 | |
if a[i] == curr | |
ret += 1 | |
curr += 2 | |
i += 2 | |
else | |
curr += 1 | |
i += 1 | |
end | |
end | |
puts ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment