結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2017-01-13 10:37:58 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 92 ms / 1,000 ms |
コード長 | 789 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-12-24 11:57:31 |
合計ジャッジ時間 | 5,451 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
コンパイルメッセージ
Syntax OK
ソースコード
d = gets.strip.to_i #p d week1 = gets.strip week2 = gets.strip #p week1 #p week2 weeks = "x" * d + week1 + week2 + "x" * d #p weeks def count_max_o(weeks) count_max = 0 count = 0 (0...weeks.length).each do |i| if weeks[i] == 'o' count += 1 else if count > count_max count_max = count end count = 0 end end if count > count_max count_max = count end #p count_max return count_max end count_max = 0 count = 0 i = 0 while i < weeks.length do if weeks[i] == 'o' i += 1 next end weeks1 = weeks.clone (0...d).each do |j| if weeks[i + j] == 'o' break else weeks1[i + j] = 'o' end end #p weeks1 count = count_max_o(weeks1) if count > count_max count_max = count end i += 1 end if d == 0 p count_max_o(weeks) else p count_max end