Submission
Status:
PPPPPPPPPP
Score: 100
User: Ecir
Problemset: Consecutive Subsequence
Language: cpp
Time: 0.027 second
Submitted On: 2025-03-13 22:01:20
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define twod array<ll,2>
vector<int> ans;
vector<int> vct;
int mX=0;
unordered_map<int,bool> mp;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
bool b=0;
string c;
int u=0;
while(cin >> c){
int z=0;
if(!(c[0]=='-' || (c[0]>='0' && c[0]<='9'))){
break;
}
if(c[0]=='-'){
for(int i=1;i<c.size();i++){
z*=10;
z+=int(c[i]-'0');
}
z*=(-1);
}
else{
for(int i=0;i<c.size();i++){
z*=10;
z+=int(c[i]-'0');
}
}
mp[z]=1;
}
for(int i=-100000;i<=100000;i++){
if(mp[i]==1 && mp[i-1]==1){
vct.push_back(i);
}
else if(mp[i]==1){
if(ans.size()<vct.size()) ans=vct;
vct.clear();
vct.push_back(i);
}
}
for(auto e:ans) cout << e << " ";
return 0;
}