Last active
November 5, 2015 16:39
-
-
Save whatalnk/02bd56259c2a572c4b91 to your computer and use it in GitHub Desktop.
Codeforces #329 Div2
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/593/problem/A) | |
n = gets.chomp.to_i | |
d = Hash.new(0) | |
n.times do | |
word = gets.chomp | |
k = word.split("").uniq.sort | |
v = word.length | |
d[k] += v if k.length <= 2 | |
end | |
res = 0 | |
(?a..?z).to_a.combination(2) do |kk| | |
res = [res, d[[kk[0]]] + d[[kk[1]]] + d[kk]].max | |
end | |
puts res |
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/593/problem/B) | |
n = gets.chomp.to_i | |
x1, x2 = gets.chomp.split(" ").map(&:to_i) | |
x1 += 1.0e-10 | |
x2 -= 1.0e-10 | |
ary = [] | |
n.times do |i| | |
k, b = gets.chomp.split(" ").map(&:to_f) | |
ary << [i, (x1)*k+b, (x2)*k+b] | |
end | |
ary1 = ary.sort_by{|v| v[1]} | |
ary2 = ary.sort_by{|v| v[2]} | |
if ary1 == ary2 then | |
puts "NO" | |
else | |
puts "YES" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Codeforces Round #329 (Editorial) - Codeforces