結果

問題 No.3757 Happy End
コンテスト
ユーザー uuuus17
提出日時 2026-10-09 21:37:51
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 68 ms / 2,000 ms
+ 185µs
コード長 1,891 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 64 ms
コンパイル使用メモリ 83,696 KB
実行使用メモリ 100,896 KB
最終ジャッジ日時 2026-10-09 21:38:07
合計ジャッジ時間 4,419 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = lambda: sys.stdin.readline().rstrip()
# sys.setrecursionlimit(10**7)
# sys.set_int_max_str_digits(10**6)
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
def lm1(LIST): return list(map(lambda x:x-1, LIST))
def mps(A):return [tuple(map(int, input().split())) for _ in range(A)]
def stoi(LIST):return list(map(int,LIST))
def itos(LIST):return list(map(str,LIST))
def atoi(LIST): return [ord(i)-ord("a") for i in LIST]
def Atoi(LIST): return [ord(i)-ord("A") for i in LIST]
def LT(LIST,N): return LIST[bisect.bisect_left(LIST,N)-1]
def LE(LIST,N): return LIST[bisect.bisect_right(LIST,N)-1]
def GT(LIST,N): return LIST[bisect.bisect_right(LIST,N)]
def GE(LIST,N): return LIST[bisect.bisect_left(LIST,N)]
def LTidx(LIST,N): return bisect.bisect_left(LIST,N)-1
def LEidx(LIST,N): return bisect.bisect_right(LIST,N)-1
def GTidx(LIST,N): return bisect.bisect_right(LIST,N)
def GEidx(LIST,N): return bisect.bisect_left(LIST,N)
def bitA(X,A):return X & 1<<A == 1<<A
def gtoi(x,y,h,w):return x*w+y
def in_grid(x,y,h,w):return 0 <= x < h and 0 <= y < w
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
def pmat(list):
    for i in list:print(*i)
import math
import bisect
import heapq
from copy import copy as cc
from copy import deepcopy as dc
from itertools import accumulate, product
from collections import Counter, defaultdict, deque
m4 = [[1,0],[0,1],[-1,0],[0,-1]]
m8 = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
inf = (1<<63)-1
mod = 998244353

n = int(input())
s = list(input())
ans = 0
end = s[-5:]
w = "HAPPY"
for i in range(5):
    if w[i] != end[i]:ans += 1
s = s[:-5]
for i in range(len(s)-4):
    flag = True
    for j in range(5):
        if s[i+j] != w[j]:flag = False
    if flag:
        s[i+4] = "B"
        ans += 1
print(ans)
0