結果

問題 No.996 Phnom Penh
ユーザー titia
提出日時 2020-04-08 04:01:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 760 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,556 KB
最終ジャッジ日時 2024-07-16 02:24:55
合計ジャッジ時間 9,570 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
LEN=len(S)
S+="z"*100

LEN=len(S)

L=[]
for i in range(LEN):
    if S[i:i+3]=="phn":
        s=0
        j=i+3
        while S[j:j+2]=="om":
            s+=1
            j+=2
        L.append(s)

if L==[]:
    ANS=0
else:
    ANS=max(L)+sum(L)+1

T=""
for s in S:
    if s=="h":
        continue
    if s=="e":
        T+="h"
    else:
        T+=s

if S==T:
    print(ANS)
    
else:    
    L=[]
    for i in range(len(T)):
        if T[i:i+3]=="phn":
            s=0
            j=i+3
            while T[j:j+2]=="om":
                s+=1
                j+=2
            L.append(s)

    if L==[]:
        if "h" in T:
            ANS2=2
        else:
            ANS2=1
        
    else:
        ANS2=max(L)+sum(L)+2

    print(max(ANS,ANS2))
0