CSES - Datatähti 2017 loppu - Results
Submission details
Task:Mex-luku
Sender:Senpai
Submission time:2017-01-19 17:09:07 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:22:2: error: no 'operator--(int)' declared for postfix '--' [-fpermissive]
 t--;
  ^

Code

#include <bits/stdc++.h>
using namespace std;
long long n,k,x,d,e,h;
vector<int>v;
multiset<int>s;
multiset<int>t;
int main(){
cin>>n>>k;
for(int i=0; i<k-1; i++){
cin>>x;
v.push_back(x);
t.insert(x);
}

for(int i=k-1; i<n; i++){
cin>>x;
v.push_back(x);
t.insert(x);
auto it=t.begin();
auto ti=t.begin();
auto ku=t.end();
t--;
ti++;
if(t.count(0)>0) cout<<0<<" ";
else{
while(abs(*it-*ti)==1){

it++;
ti++;
if(*it==*ku){h++;
break;
}
}
if(h==1)cout<<*t.end()+1<<" ";
else{
e=*it;
cout<<e+1<<" ";}
}
d=v[i-k+1];
t.erase(t.find(d));
h=0;

}

}