Create a gist now

Instantly share code, notes, and snippets.

Codeforces #329 Div2
# [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
# [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
@whatalnk
Owner
whatalnk commented Nov 5, 2015
  • A
  • B
  • C
  • D
  • E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment