結果

問題 No.145 yukiover
ユーザー maspymaspy
提出日時 2020-03-03 23:25:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 239 ms / 5,000 ms
コード長 900 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,144 KB
最終ジャッジ日時 2024-04-22 00:49:40
合計ジャッジ時間 2,542 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 27 ms
10,880 KB
testcase_04 AC 26 ms
10,624 KB
testcase_05 AC 26 ms
10,624 KB
testcase_06 AC 26 ms
10,624 KB
testcase_07 AC 26 ms
10,752 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 32 ms
12,416 KB
testcase_12 AC 57 ms
14,144 KB
testcase_13 AC 43 ms
13,520 KB
testcase_14 AC 83 ms
13,244 KB
testcase_15 AC 129 ms
12,800 KB
testcase_16 AC 239 ms
12,424 KB
testcase_17 AC 84 ms
13,628 KB
testcase_18 AC 69 ms
13,500 KB
testcase_19 AC 77 ms
13,500 KB
testcase_20 AC 74 ms
13,624 KB
testcase_21 AC 58 ms
13,628 KB
testcase_22 AC 67 ms
13,496 KB
testcase_23 AC 62 ms
12,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter

# %%
N = int(readline())
S = read().rstrip().decode()


# %%
def test(n, alphabets, word):
    """alphabetsを使ってwordより真に大きいものをn個つくれる"""
    if n <= 0:
        return True
    if not word:
        return len(alphabets) >= n
    w = word[0]
    while alphabets and alphabets[-1] > w:
        alphabets.pop()
        n -= 1
    if n <= 0:
        return True
    if len(alphabets) < n:
        return False
    if alphabets[-n] < w:
        return False
    return test(n, alphabets[:-n], word[1:])


# %%
A = sorted(S)
left = 0
right = N + 1
while left + 1 < right:
    x = (left + right) // 2
    if test(x, A[:], 'yuki'):
        left = x
    else:
        right = x


# %%
print(left)
0