Code Submission Evaluation System Login

Datatähti 2017 loppu

Start:2017-01-19 12:15:00
End:2017-01-19 17:15:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - Datatähti 2017 loppu - Results
History
2017-01-19 21:35:2728
2017-01-19 17:14:49
2017-01-19 17:13:520
2017-01-19 17:13:020
2017-01-19 17:12:110
2017-01-19 17:11:130
2017-01-19 17:10:410
2017-01-19 17:09:260
2017-01-19 17:09:07
2017-01-19 17:08:110
2017-01-19 17:06:130
2017-01-19 17:05:190
2017-01-19 17:02:040
2017-01-19 16:59:140
2017-01-19 16:59:020
2017-01-19 16:58:030
2017-01-19 16:57:29
2017-01-19 16:56:15
2017-01-19 16:55:36
2017-01-19 16:47:160
2017-01-19 16:46:290
2017-01-19 16:36:530
2017-01-19 16:04:430
2017-01-19 16:04:17
2017-01-19 15:58:070
2017-01-19 15:47:560
2017-01-19 15:42:270
2017-01-19 15:40:290
2017-01-19 15:35:270
2017-01-19 15:29:100
2017-01-19 15:27:420
2017-01-19 15:08:140
2017-01-19 15:07:43
2017-01-19 15:06:000
2017-01-19 15:04:520
2017-01-19 14:49:390
2017-01-19 14:49:19
2017-01-19 14:40:550
2017-01-19 14:38:450
2017-01-19 14:37:450
2017-01-19 14:36:540
2017-01-19 14:36:190
2017-01-19 14:35:44
2017-01-19 14:35:09
Task:Mex-luku
Sender:Senpai
Submission time:2017-01-19 17:14:49
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:34:1: error: 'else' without a previous 'if'
 else{
 ^
input/code.cpp:38:5: error: 'i' was not declared in this scope
 d=v[i-k+1];
     ^
input/code.cpp: At global scope:
input/code.cpp:44:1: error: expected declaration before '}' token
 }
 ^

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();
ku--;
ti++;
if(t.count(0)==0) cout<<0<<" ";
else{
while(abs(*it-*ti)==1){

it++;
ti++;

}
}

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

}

}