Created
November 4, 2017 16:10
-
-
Save whatalnk/7c16ded52cc195a3283859246797ca60 to your computer and use it in GitHub Desktop.
AtCoder ABC #077
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
s1 = gets.chomp | |
s2 = gets.chomp | |
if s1 == s2.reverse && s2 == s1.reverse | |
puts "YES" | |
else | |
puts "NO" | |
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
n = gets.chomp.to_i | |
a = Math.sqrt(n).to_i | |
puts a**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
N = gets.chomp.to_i | |
A = gets.chomp.split(" ").map(&:to_i).sort | |
B = gets.chomp.split(" ").map(&:to_i).sort | |
C = gets.chomp.split(" ").map(&:to_i).sort | |
memo = Array.new(N, 0) | |
N.times do |ib| | |
ic = C.bsearch_index{|x| x > B[ib]} | |
next if ic.nil? | |
memo[ib] = (N - ic) | |
end | |
(N-1).downto(1) do |i| | |
memo[i - 1] += memo[i] | |
end | |
ans = 0 | |
A.each do |a| | |
ib = B.bsearch_index{|x| x > a} | |
next if ib.nil? | |
ans += memo[ib] | |
end | |
puts ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment