結果

問題 No.2334 Distinct Cards
ユーザー pseudosodiumpseudosodium
提出日時 2023-06-02 21:26:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,955 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 211,928 KB
実行使用メモリ 10,152 KB
最終ジャッジ日時 2023-08-28 02:43:41
合計ジャッジ時間 3,748 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 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 23 ms
4,376 KB
testcase_18 AC 50 ms
6,768 KB
testcase_19 AC 48 ms
10,152 KB
testcase_20 AC 17 ms
4,380 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 13 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

template <typename T> istream& operator >> (istream& in, vector<T>& v) { for (auto &it:v) in >> it; return in; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (auto it:v) os << it << " "; return os; }
template <typename T1, typename T2> istream& operator >> (istream& in, pair<T1,T2>& p) { in >> p.first >> p.second; return in; }
template <typename T1, typename T2> ostream& operator << (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
// auto operator<<(ostream&o,auto&&v)->enable_if_t<!is_constructible_v<string,decltype(v)>,decltype(o<<*end(v))>{int f=0,u=&o!=&cerr;o<<"["+u;for(auto&&x:v)(f++?o<<", "+u:o)<<x;return o<<"]"+u;}
// auto operator<<(ostream&o,auto&&t)->decltype(o<<get<0>(t)){int f=0,u=&o!=&cerr;o<<"<"+u;apply([&](auto&...x){(((f++?o<<", "+u:o)<<x),...);},t);return o<<">"+u;}
template <typename T1, typename T2> void minn(T1& a, T2 b) { a = min(a,b); }
template <typename T1, typename T2> void maxx(T1& a, T2 b) { a = max(a,b); }

#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define deb(x) cerr<<#x<<"="<<x<<'\n';

const int mod = 1e9L + 7;
const int mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795;
const int raw_mango_seed = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(raw_mango_seed);

void solve() {
    int n,k; cin>>n>>k;
    vector<int> a(n); cin>>a;
    sort(all(a));
    map<int,int> m;
    int ans=k;
    for(int i=0;i<k;i++) m[a[i]]++;
    minn(ans,sz(m));
    for(int i=k;i<n;i++){
        m[a[i-k]]--;
        if(m[a[i-k]]==0)m.erase(a[i-k]);
        m[a[i]]++;
        minn(ans,sz(m));
    }
    cout<<ans<<'\n';
}

int32_t main() {
    
    cin.tie(0)->sync_with_stdio(0);
    int tc=1;
    // cin>>tc;
    while(tc--){
        solve();
    }
    return 0;
}
0