結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-03 23:25:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 251 ms / 5,000 ms |
| コード長 | 868 bytes |
| コンパイル時間 | 206 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 13,888 KB |
| 最終ジャッジ日時 | 2024-10-13 23:22:41 |
| 合計ジャッジ時間 | 2,254 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
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)
maspy