Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: meme_boi2
Problemset: Consecutive Subsequence
Language: cpp
Time: 0.003 second
Submitted On: 2025-11-02 20:36:16
#include <bits/stdc++.h>
using namespace std;
int32_t main(){
cin.tie(nullptr)->sync_with_stdio(0);
vector<int> mat;
while(1){
string txt;
cin >> txt;
if(isalpha(txt[0])){
break;
}else mat.push_back(stoi(txt));
}
int l = 0, r = 0,ll = 0,rr = 0, n = mat.size();
sort(mat.begin(),mat.end());
mat.erase(unique(mat.begin(),mat.end()),mat.end());
n = mat.size();
for(r = 1; r < n; r++){
if(mat[r]-mat[r-1] == 1){
//cout << l << ' ' << r << '\n';
if(r-l > rr-ll){
rr = r;
ll = l;
}
}else{
l = r;
}
}
// for(int i = 0; i < n; i++) cout << mat[i] << ' ';
//cout << ll << ' ' << rr << '\n';
for(int i = ll; i <= rr; i++){
cout << mat[i] << ' ';
}
}