結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー rocoder
提出日時 2017-07-16 05:56:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 36 ms / 1,000 ms
コード長 833 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-12-24 12:00:52
合計ジャッジ時間 4,195 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#golden week
D=int(input())
C1=input()
C2=input()
C=C1+C2
i=0
Cn=[D]
co=0
while i <len(C) and C[i]=="x":
    co+=1
    i+=1
    Cn[0]+= co
while i<len(C):
    co=0
    while i <len(C) and C[i]=="o":
        co+=1
        i+=1
    Cn.append (co)
    co=0
    while i <len(C) and C[i]=="x":
        co+=1
        i+=1
    Cn.append (co)
Cn[-1]+=D
m=0
j=0
#print (Cn)
while j<len(Cn):
    V=D
    i=j
  #  print (i)
    g=0
    while i<len(Cn) and V>=0:
        if i%2==1:
            g+=Cn[i]
     #       print (g)
        elif V>=Cn[i]:
            g+=Cn[i]
            V=0
        elif V>0:
            if g==0:
                g+=V
                V=0
            else:
                g+=V
                V=-1
        else:
            V=-1
        i+=1
   #     print (g)
 #   print (g)
    if g>m:
        m=g
    j+=1
print(m)
0