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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:22:16: error: no match for 'operator+' (operand types are 'std::_Rb_tree_const_iterator<int>' and 'int')
 while(*it==*(it+1)){
                ^
input/code.cpp:22:16: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/sstream:38,
                 from /usr/include/c++/4.8/complex:45,
                 from /usr/include/c++/4.8/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from input/code.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:333:5: note: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)...

Code

#include <bits/stdc++.h>
using namespace std;
long long n,k,x,d,e;
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();
if(t.count(1)==0) cout<<0<<" ";
else{
while(*it==*(it+1)){
it++;}
e=*it;
cout<<e+1<<" ";
}
d=v[i-k+1];
t.erase(d)

}

}