Submission #20724236


Source Code Expand

/** author: samari06,  created: 06.03.2021 22:07:50 **/
#include <bits/stdc++.h>
#define REP(i, N) for(int i = 0; i < (int)N; i++)
#define CREP(i, l, r) for(int i = l; i <= r; i++)
using namespace std;
typedef long long ll;
const int INF = 1000000010;      // > 10^9,


int main(){
    int n,m; cin >> n >> m;
    vector<int> a(n);
    REP(i,n) scanf("%d",&a[i]);

    set<int> st;
    REP(i,n+2) st.insert(i);
    vector<int> ch(n+2,0);
    REP(i,m-1){
        auto itr = st.find(a[i]);
        if(itr != st.end()) st.erase(itr);
        else ch[a[i]]++;
    }
    int res = INF;
    CREP(i,m-1,n-1){
        auto itr = st.find(a[i]);
        if(itr != st.end()) st.erase(itr);
        else ch[a[i]]++;

        auto itr2 = st.begin();
        res = min(res, *itr2);

        //auto itr3 = st.find(a[i]);
        if(ch[a[i-m+1]] == 0) st.insert(a[i-m+1]);
        else ch[a[i-m+1]]--;
    }

    cout << res;
    return 0;
}

Submission Info

Submission Time
Task E - Mex Min
User samari06
Language C++ (GCC 9.2.1)
Score 500
Code Size 963 Byte
Status AC
Exec Time 2120 ms
Memory 85412 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   13 |     REP(i,n) scanf("%d",&a[i]);
      |              ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All answer_n_00.txt, answer_n_01.txt, gu_killer_00.txt, gu_killer_01.txt, gu_killer_02.txt, handmade_00.txt, handmade_01.txt, handmade_02.txt, handmade_03.txt, large_answer_00.txt, large_answer_01.txt, large_answer_02.txt, large_answer_03.txt, large_answer_04.txt, large_answer_05.txt, large_answer_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, same_00.txt, same_01.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
answer_n_00.txt AC 2120 ms 85308 KiB
answer_n_01.txt AC 927 ms 45620 KiB
gu_killer_00.txt AC 698 ms 85268 KiB
gu_killer_01.txt AC 675 ms 85320 KiB
gu_killer_02.txt AC 710 ms 85308 KiB
handmade_00.txt AC 3 ms 3676 KiB
handmade_01.txt AC 2 ms 3480 KiB
handmade_02.txt AC 2 ms 3660 KiB
handmade_03.txt AC 2 ms 3560 KiB
large_answer_00.txt AC 703 ms 85364 KiB
large_answer_01.txt AC 670 ms 85336 KiB
large_answer_02.txt AC 668 ms 85220 KiB
large_answer_03.txt AC 703 ms 85412 KiB
large_answer_04.txt AC 320 ms 40840 KiB
large_answer_05.txt AC 123 ms 18956 KiB
large_answer_06.txt AC 457 ms 62620 KiB
random_00.txt AC 572 ms 85316 KiB
random_01.txt AC 1021 ms 85404 KiB
random_02.txt AC 562 ms 85412 KiB
random_03.txt AC 799 ms 66048 KiB
random_04.txt AC 390 ms 44384 KiB
random_05.txt AC 21 ms 5860 KiB
same_00.txt AC 553 ms 85220 KiB
same_01.txt AC 604 ms 85192 KiB
sample_01.txt AC 3 ms 3620 KiB
sample_02.txt AC 5 ms 3484 KiB
sample_03.txt AC 2 ms 3480 KiB
sample_04.txt AC 3 ms 3488 KiB