結果

問題 No.2334 Distinct Cards
ユーザー moharan627moharan627
提出日時 2023-06-02 21:53:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 106,072 KB
最終ジャッジ日時 2023-08-28 03:18:03
合計ジャッジ時間 4,327 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,556 KB
testcase_01 AC 88 ms
71,604 KB
testcase_02 AC 87 ms
71,636 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 91 ms
71,568 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 154 ms
106,072 KB
testcase_18 AC 159 ms
106,004 KB
testcase_19 AC 149 ms
105,800 KB
testcase_20 AC 122 ms
90,700 KB
testcase_21 AC 118 ms
90,368 KB
testcase_22 AC 115 ms
90,524 KB
testcase_23 AC 88 ms
71,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
#10**20,2**63に変えるのもあり
MOD = 10**9 + 7
MOD2 = 998244353
from collections import defaultdict
def ceil(A,B):
    return -(-A//B)
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N,K = MI()
    A = LI()
    C = defaultdict(lambda:0)
    A.sort()
    Ans = INF
    S = 0
    for i in range(K):
        C[A[i]]+=1
        if(C[A[i]]==1):S+=1
    Ans = min(Ans,S)
    for i in range(N-K):
        C[A[i+K]]+=1
        if(C[A[i+K]]==1):S+=1
        C[A[i]]-=1
        if(C[A[i]]==0):S-=1
        Ans = min(Ans,S)
    print(Ans)
    return
solve()
0