結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-14 16:03:22
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-05-05 19:20:23
合計ジャッジ時間 5,760 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,160 KB
testcase_01 AC 93 ms
12,032 KB
testcase_02 AC 96 ms
12,160 KB
testcase_03 AC 87 ms
12,032 KB
testcase_04 AC 90 ms
12,288 KB
testcase_05 AC 87 ms
12,160 KB
testcase_06 AC 88 ms
12,160 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 89 ms
12,160 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 88 ms
12,288 KB
testcase_23 WA -
testcase_24 AC 87 ms
12,160 KB
testcase_25 AC 88 ms
12,160 KB
testcase_26 AC 88 ms
12,288 KB
testcase_27 AC 88 ms
12,416 KB
testcase_28 AC 90 ms
12,160 KB
testcase_29 AC 88 ms
12,288 KB
testcase_30 AC 88 ms
12,288 KB
testcase_31 AC 87 ms
12,160 KB
testcase_32 AC 87 ms
12,288 KB
testcase_33 AC 88 ms
12,160 KB
testcase_34 AC 87 ms
12,288 KB
testcase_35 AC 88 ms
12,160 KB
testcase_36 AC 88 ms
12,032 KB
testcase_37 AC 88 ms
12,288 KB
testcase_38 AC 90 ms
12,288 KB
testcase_39 AC 88 ms
12,160 KB
testcase_40 AC 89 ms
12,288 KB
testcase_41 AC 88 ms
12,160 KB
testcase_42 AC 89 ms
12,160 KB
testcase_43 AC 88 ms
12,288 KB
testcase_44 AC 92 ms
12,032 KB
testcase_45 AC 90 ms
12,288 KB
testcase_46 AC 88 ms
12,160 KB
testcase_47 AC 88 ms
12,288 KB
testcase_48 AC 89 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(s)
	arr=[]
	old=""
	p1=0
	s.chars{|e|
		if old==e
			if e=="o"
				p1+=1
			else
				p1-=1
			end
		else
			arr<<p1
			if e=="o"
				p1=1
			else
				p1=-1
			end
		end
		old=e
	}
	arr<<p1
	arr.shift
	return arr
end
def g(s,n)
	ans=[n,s.max,s[0]+n,s.last+n].max
	s.size.times{|i|
		if s[i]<0
			t=-s[i]
			if t>n
				if i>0
					ans=[ans,n+s[i-1]].max
				end
				if i<s.size-1
					ans=[ans,n+s[i+1]].max
				end
			else
				t2=t
				if i>0
					t2+=s[i-1]
				end
				if i<s.size-1
					t2+=s[i+1]
				end
				ans=[ans,t2].max
			end
		end
	}
 
	return ans
end
 
n=gets.to_i
s=gets.chomp+gets.chomp
puts g(f(s),n)
0