Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active October 24, 2016 00:33
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/18c54579ddfef9c64a7534ed5822cae3 to your computer and use it in GitHub Desktop.
Save whatalnk/18c54579ddfef9c64a7534ed5822cae3 to your computer and use it in GitHub Desktop.
Code Festival 予選C
s = gets.chomp
c = s.index("C")
ret = false
if !c.nil? then
f = s[c..(s.length-1)].index("F")
if !f.nil?
ret = true
end
end
if ret then
puts "Yes"
else
puts "No"
end
k, t = gets.chomp.split(" ").map(&:to_i)
aa = gets.chomp.split(" ").map(&:to_i).sort
aamax = aa.last
puts [aamax - 1 - (k - aamax), 0].max
n = gets.chomp.to_i
tt = gets.chomp.split(" ").map(&:to_i)
aa = gets.chomp.split(" ").map(&:to_i)
htt = Array.new(n, nil)
tt.each_with_index do |e, i|
if i == 0 || tt[i-1] < e then
htt[i] = e
end
end
haa = Array.new(n, nil)
aa.each_with_index do |e, i|
if i == (n - 1) || aa[i + 1] < e then
haa[i] = e
end
end
ret = 1
tt.zip(aa).each_with_index do |e, i|
if haa[i] && e[0] < haa[i] then
puts 0; exit
elsif htt[i] && e[1] < htt[i] then
puts 0; exit
elsif htt[i] || haa[i] then
next
end
ret *= e.min
ret %= (10**9 + 7)
end
puts ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment