Last active
December 1, 2015 10:21
-
-
Save whatalnk/5b7699d7bd321317deb7 to your computer and use it in GitHub Desktop.
Educational Codeforces Round 2
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
# [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 |
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
# [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(" ") |
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