結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-19 21:38:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 1,000 ms
コード長 939 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-08-25 23:45:38
合計ジャッジ時間 6,513 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,112 KB
testcase_01 AC 81 ms
15,144 KB
testcase_02 AC 80 ms
15,052 KB
testcase_03 AC 81 ms
15,324 KB
testcase_04 AC 80 ms
15,200 KB
testcase_05 AC 81 ms
15,356 KB
testcase_06 AC 80 ms
15,120 KB
testcase_07 AC 81 ms
15,196 KB
testcase_08 AC 79 ms
15,140 KB
testcase_09 AC 81 ms
15,160 KB
testcase_10 AC 81 ms
15,084 KB
testcase_11 AC 80 ms
15,096 KB
testcase_12 AC 82 ms
15,164 KB
testcase_13 AC 80 ms
15,116 KB
testcase_14 AC 81 ms
15,000 KB
testcase_15 AC 82 ms
15,152 KB
testcase_16 AC 80 ms
15,084 KB
testcase_17 AC 81 ms
15,316 KB
testcase_18 AC 79 ms
15,084 KB
testcase_19 AC 80 ms
15,144 KB
testcase_20 AC 80 ms
15,276 KB
testcase_21 AC 80 ms
15,088 KB
testcase_22 AC 80 ms
15,172 KB
testcase_23 AC 81 ms
15,160 KB
testcase_24 AC 81 ms
15,092 KB
testcase_25 AC 81 ms
15,004 KB
testcase_26 AC 81 ms
15,188 KB
testcase_27 AC 79 ms
15,332 KB
testcase_28 AC 80 ms
15,264 KB
testcase_29 AC 81 ms
15,324 KB
testcase_30 AC 80 ms
15,012 KB
testcase_31 AC 80 ms
15,312 KB
testcase_32 AC 80 ms
15,164 KB
testcase_33 AC 81 ms
15,256 KB
testcase_34 AC 81 ms
15,140 KB
testcase_35 AC 82 ms
15,264 KB
testcase_36 AC 81 ms
15,148 KB
testcase_37 AC 82 ms
15,228 KB
testcase_38 AC 81 ms
15,140 KB
testcase_39 AC 80 ms
15,168 KB
testcase_40 AC 81 ms
15,144 KB
testcase_41 AC 81 ms
15,052 KB
testcase_42 AC 83 ms
15,084 KB
testcase_43 AC 82 ms
15,000 KB
testcase_44 AC 79 ms
15,172 KB
testcase_45 AC 80 ms
15,224 KB
testcase_46 AC 81 ms
15,144 KB
testcase_47 AC 82 ms
15,228 KB
testcase_48 AC 81 ms
15,260 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

d = gets.to_i
c = gets.strip
c += gets.strip
a = Array.new
count = 0
(c.length - 1).times do |i|
    if c[i] == c[i + 1]
        count += 1
    else
        a.push(count + 1)
        count = 0
    end
end
a.push(count + 1)
alen = a.length
s = c[0]
if alen == 1
    if s == "o"
        puts a[0] + d
        exit
    else
        puts d
        exit
    end
end
max = 0
st = (s == "o") ? 0 : 1
st.step(alen - 1, 2) do |i|
	m1 = 0
	m2 = 0
	if i + 1 < alen
		diff = d - a[i + 1]
		if diff >= 0
			if i + 2 < alen
				m1 = a[i] + a[i + 1] + a[i + 2]
			else
				m1 = a[i] + d
			end
		else
			m1 = a[i] + d
		end
	else
		m1 = a[i] + d
	end
	if i - 1 >= 0
		diff = d - a[i - 1]
		if diff >= 0
			if i - 2 >= 0
				m2 = a[i] + a[i - 1] + a[i - 2]
			else
				m2 = a[i] + d
			end
		else
			m2 = a[i] + d
		end
	else
		m1 = a[i] + d
	end
	#print m1, " ", m2, "\n"
    if m1 > max
        max = m1
    end
	if m2 > max
		max = m2
	end
end
puts max
0