結果
問題 | No.145 yukiover |
ユーザー | Mao-beta |
提出日時 | 2024-03-19 01:48:22 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,311 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 82,500 KB |
実行使用メモリ | 73,892 KB |
最終ジャッジ日時 | 2024-09-30 05:13:06 |
合計ジャッジ時間 | 2,440 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
57,640 KB |
testcase_01 | AC | 45 ms
56,920 KB |
testcase_02 | AC | 44 ms
56,904 KB |
testcase_03 | AC | 45 ms
57,284 KB |
testcase_04 | AC | 42 ms
56,356 KB |
testcase_05 | AC | 43 ms
57,264 KB |
testcase_06 | AC | 42 ms
56,456 KB |
testcase_07 | AC | 42 ms
56,884 KB |
testcase_08 | WA | - |
testcase_09 | AC | 46 ms
55,952 KB |
testcase_10 | AC | 43 ms
56,372 KB |
testcase_11 | AC | 55 ms
71,928 KB |
testcase_12 | AC | 55 ms
71,832 KB |
testcase_13 | AC | 54 ms
72,308 KB |
testcase_14 | AC | 56 ms
72,908 KB |
testcase_15 | WA | - |
testcase_16 | AC | 53 ms
72,164 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 57 ms
72,900 KB |
testcase_20 | AC | 53 ms
72,452 KB |
testcase_21 | WA | - |
testcase_22 | AC | 53 ms
73,628 KB |
testcase_23 | AC | 54 ms
71,972 KB |
ソースコード
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()