結果

問題 No.145 yukiover
ユーザー kimiyuki
提出日時 2016-12-27 18:36:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 168 ms / 5,000 ms
コード長 750 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-12-15 03:50:00
合計ジャッジ時間 3,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import collections
# abcdefghijklmnopqrstuvwxyz
#         4 3         2   1
_ = int(input())
cnt = collections.Counter()
for c in input():
    cnt[c] += 1
def take(c, z=None):
    if z is None:
        z = c
    while c <= z:
        if cnt[c]:
            cnt[c] -= 1
            return c
        c = chr(ord(c) + 1)
    return ''
def construct(s):
    acc = ''
    for c in s:
        if c.islower():
            acc += take(c)
        elif c.isupper():
            acc += take(c.lower(), 'z')
    if len(acc) < len(s):
        for c in acc:
            cnt[c] += 1
        return False
    else:
        return True
ans = 0
for s in [ 'yukiA', 'yukJ', 'yuL', 'yV', 'Z' ]:
    while construct(s):
        ans += 1
print(ans)
0