結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-14 15:57:34
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-05-05 19:09:33
合計ジャッジ時間 5,106 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 80 ms
12,160 KB
testcase_02 AC 75 ms
11,904 KB
testcase_03 AC 75 ms
12,160 KB
testcase_04 AC 76 ms
12,160 KB
testcase_05 WA -
testcase_06 AC 79 ms
12,160 KB
testcase_07 AC 80 ms
12,160 KB
testcase_08 AC 82 ms
11,904 KB
testcase_09 WA -
testcase_10 AC 83 ms
12,288 KB
testcase_11 AC 76 ms
12,160 KB
testcase_12 AC 74 ms
12,032 KB
testcase_13 WA -
testcase_14 AC 75 ms
12,160 KB
testcase_15 AC 73 ms
12,160 KB
testcase_16 AC 74 ms
12,288 KB
testcase_17 AC 73 ms
12,160 KB
testcase_18 WA -
testcase_19 AC 75 ms
12,160 KB
testcase_20 WA -
testcase_21 AC 75 ms
12,160 KB
testcase_22 WA -
testcase_23 AC 75 ms
12,160 KB
testcase_24 WA -
testcase_25 AC 75 ms
12,160 KB
testcase_26 WA -
testcase_27 AC 75 ms
12,160 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 79 ms
12,160 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 75 ms
12,160 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 73 ms
12,160 KB
testcase_38 AC 73 ms
12,032 KB
testcase_39 AC 75 ms
12,160 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 RE -
testcase_43 AC 77 ms
12,160 KB
testcase_44 AC 78 ms
12,032 KB
testcase_45 AC 77 ms
12,160 KB
testcase_46 AC 75 ms
12,160 KB
testcase_47 WA -
testcase_48 AC 75 ms
12,160 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.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