Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Educational Codeforces Round 2
# [Problem - A - Codeforces](http://codeforces.com/contest/600/problem/A)
s = gets.chomp.split(/[,;]/, -1)
number = []
nonnumber = []
s.each do |w|
if w.match(/^[0-9]+$/) then
if w.length >= 2 and w[0] == "0" then
nonnumber << w
else
number << w
end
else
nonnumber << w
end
end
if number.length == 0 then
puts "-"
else
p number.join(",")
end
if nonnumber.length == 0 then
puts "-"
else
p nonnumber.join(",")
end
# [Problem - B - Codeforces](http://codeforces.com/contest/600/problem/B)
n, m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i).sort
b = gets.chomp.split(" ").map(&:to_i)
res = Array.new()
b.each do |e|
tmp = (0...n).bsearch {|i| a[i] > e}
if tmp.nil? then
res << n
else
res << tmp
end
end
puts res.join(" ")
Owner

whatalnk commented Dec 1, 2015

  • A
  • B
  • C
  • D
  • E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment