Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active November 5, 2015 16:39
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/02bd56259c2a572c4b91 to your computer and use it in GitHub Desktop.
Save whatalnk/02bd56259c2a572c4b91 to your computer and use it in GitHub Desktop.
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
Copy link
Author

whatalnk commented Nov 5, 2015

@whatalnk
Copy link
Author

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