Last active
October 24, 2016 00:33
-
-
Save whatalnk/18c54579ddfef9c64a7534ed5822cae3 to your computer and use it in GitHub Desktop.
Code Festival 予選C
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
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 |
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
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 |
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 | |
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