結果
問題 | No.145 yukiover |
ユーザー | Mao-beta |
提出日時 | 2024-03-19 01:51:42 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,362 bytes |
コンパイル時間 | 320 ms |
コンパイル使用メモリ | 82,196 KB |
実行使用メモリ | 73,640 KB |
最終ジャッジ日時 | 2024-09-30 05:13:14 |
合計ジャッジ時間 | 2,356 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
56,932 KB |
testcase_01 | AC | 45 ms
57,188 KB |
testcase_02 | AC | 44 ms
56,228 KB |
testcase_03 | AC | 47 ms
56,664 KB |
testcase_04 | AC | 45 ms
57,644 KB |
testcase_05 | AC | 45 ms
57,420 KB |
testcase_06 | AC | 46 ms
56,716 KB |
testcase_07 | AC | 47 ms
56,240 KB |
testcase_08 | AC | 45 ms
56,588 KB |
testcase_09 | AC | 45 ms
56,088 KB |
testcase_10 | WA | - |
testcase_11 | AC | 56 ms
72,228 KB |
testcase_12 | AC | 58 ms
72,108 KB |
testcase_13 | AC | 58 ms
73,252 KB |
testcase_14 | AC | 59 ms
73,424 KB |
testcase_15 | AC | 60 ms
71,968 KB |
testcase_16 | AC | 57 ms
72,956 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 59 ms
71,968 KB |
testcase_20 | AC | 60 ms
72,320 KB |
testcase_21 | AC | 59 ms
72,808 KB |
testcase_22 | AC | 58 ms
72,864 KB |
testcase_23 | AC | 59 ms
72,308 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 tmp -= g 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 tmp -= g 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 tmp -= g 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()