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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:16:32: error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
 if(s.count(1)==1)cout<<s.begin()<<" ";
                                ^
In file included from /usr/include/c++/4.8/istream:39:0,
                 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/ostream:602:5: error:   initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::_Rb_tree_const_iterator<int>]'
     operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
     ^
input/code.cpp:21:1: error: expected '}' at end of input
 }
 ^

Code

#include <bits/stdc++.h>
using namespace std;
int n,k,x,d;
vector<int>v;
multiset<int>s;
int main(){
cin>>n>>k;
d=1000000001;
for(int i=0; i<k-1; i++){
v.push_back(x);
s.insert(x+1);
for(int i=k-1; i<n; i++){
cin>>x;
v.push_back(x);
s.insert(x+1);
if(s.count(1)==1)cout<<s.begin()<<" ";
else cout<<0<<" ";
s.erase(s.find(v[i-k+1]));
}

}