結果
問題 |
No.2334 Distinct Cards
|
ユーザー |
|
提出日時 | 2023-06-02 21:53:54 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 840 bytes |
コンパイル時間 | 858 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 102,656 KB |
最終ジャッジ日時 | 2024-12-28 17:28:40 |
合計ジャッジ時間 | 3,028 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 13 |
ソースコード
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()