Submission
Status:
---PPPP-PP
Score: 60
User: osensunny
Problemset: Consecutive Subsequence
Language: cpp
Time: 0.005 second
Submitted On: 2025-03-22 23:22:27
#include<bits/stdc++.h>
using namespace std;
int l, r, mxsz=INT_MIN;
string str;
vector<int> arr;
map<int, vector<int>> mp;
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
while(true){
cin >> str;
if((str[0] >= 'a' && str[0] <= 'z') || (str[0] >= 'A' && str[0] <= 'Z')) break;
if(find(arr.begin(), arr.end(), stoi(str)) == arr.end()) arr.push_back(stoi(str));
}
sort(arr.begin(), arr.end());
while(l < arr.size() && r < arr.size()){
if(l == r || arr[r] == arr[r-1] + 1){
r++;
if(r != arr.size()) continue;
}
vector<int> tmp(arr.begin()+l, arr.begin()+r);
mp[tmp.size()] = tmp;
mxsz = max(mxsz, (int)tmp.size());
l = r;
}
for(auto x: mp[mxsz]) cout << x << ' ';
return 0;
}