結果

問題 No.145 yukiover
ユーザー Mao-betaMao-beta
提出日時 2024-03-19 01:48:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,311 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 73,052 KB
最終ジャッジ日時 2024-03-19 01:48:26
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
57,700 KB
testcase_01 AC 43 ms
57,692 KB
testcase_02 AC 43 ms
57,700 KB
testcase_03 AC 43 ms
57,696 KB
testcase_04 AC 42 ms
57,696 KB
testcase_05 AC 47 ms
57,692 KB
testcase_06 AC 43 ms
57,700 KB
testcase_07 AC 43 ms
57,696 KB
testcase_08 WA -
testcase_09 AC 44 ms
57,700 KB
testcase_10 AC 44 ms
57,700 KB
testcase_11 AC 65 ms
73,052 KB
testcase_12 AC 56 ms
73,052 KB
testcase_13 AC 57 ms
73,052 KB
testcase_14 AC 59 ms
73,052 KB
testcase_15 WA -
testcase_16 AC 56 ms
73,052 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 56 ms
73,052 KB
testcase_20 AC 57 ms
73,052 KB
testcase_21 WA -
testcase_22 AC 58 ms
73,052 KB
testcase_23 AC 57 ms
73,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


def main():
    N = NI()
    S = SI()
    alphabets = "abcdefghijklmnopqrstuvwxyz"
    D = {}
    V = [0] * 26
    v = 0
    for i, a in enumerate(alphabets):
        D[a] = i
        if a == "i": # 1
            v += 1
        elif a == "j": # 2
            v += 1
        elif a == "k": # 3
            v += 1
        elif a == "l": # 4
            v += 1
        elif a == "u": # 5
            v += 1
        elif a == "v": # 6
            v += 1
        elif a == "y": # 7
            v += 1
        elif a == "z": # 8
            v += 1
        V[i] = v

    S = [V[D[s]] for s in S]
    C = Counter(S)
    # print(C)
    ans = C[8]
    tmp = C[7]
    if C[6] >= tmp:
        ans += tmp
        tmp = 0
    else:
        ans += C[6]
        tmp -= C[6]

    if C[5] >= tmp:
        g = C[5] - tmp
        C[4] += g
    else:
        g = tmp - C[5]
        ans += g // 2
        if tmp >= g % 2:
            ans += g % 2
            tmp -= g % 2

    if C[4] >= tmp:
        ans += tmp
        tmp = 0
    else:
        ans += C[4]
        tmp -= C[4]

    if C[3] >= tmp:
        g = C[3] - tmp
        C[2] += g
    else:
        g = tmp - C[3]
        ans += g // 2
        if tmp >= g % 2:
            ans += g % 2
            tmp -= g % 2

    if C[2] >= tmp:
        ans += tmp
        tmp = 0
    else:
        ans += C[2]
        tmp -= C[2]

    if C[1] >= tmp:
        g = C[1] - tmp
        C[0] += g
    else:
        g = tmp - C[1]
        ans += g // 2
        if tmp >= g % 2:
            ans += g % 2
            tmp -= g % 2

    if C[0] >= tmp:
        ans += tmp
        tmp = 0
    else:
        ans += C[0]
        tmp -= C[0]

    if tmp > 1:
        ans += tmp // 2

    print(ans)


if __name__ == "__main__":
    main()
0