Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active December 1, 2015 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/5b7699d7bd321317deb7 to your computer and use it in GitHub Desktop.
Save whatalnk/5b7699d7bd321317deb7 to your computer and use it in GitHub Desktop.
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(" ")
@whatalnk
Copy link
Author

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