結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,544 KB
testcase_01 AC 92 ms
71,344 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 93 ms
71,684 KB
testcase_06 WA -
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 143 ms
105,068 KB
testcase_18 AC 141 ms
105,472 KB
testcase_19 AC 136 ms
105,340 KB
testcase_20 AC 121 ms
90,464 KB
testcase_21 AC 119 ms
90,436 KB
testcase_22 AC 121 ms
90,516 KB
testcase_23 AC 94 ms
71,340 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)
    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