結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2018-03-14 16:03:22 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 621 bytes |
| コンパイル時間 | 102 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-11-27 19:45:06 |
| 合計ジャッジ時間 | 5,473 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 15 |
コンパイルメッセージ
Syntax OK
ソースコード
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)
horiesiniti