Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Kittiponn
Problemset: Consecutive Subsequence
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-04 11:09:33
#include <bits/stdc++.h>
#define ll long long
#define sp << ' ' <<
#define nl << '\n'
#define cnl cout << '\n'
using namespace std;
const int nx = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;
vector<ll> ip;
int main(){
cin.tie(0)->sync_with_stdio(0);
ll n;
while(cin >> n){
ip.push_back(n);
}
sort(ip.begin(),ip.end());
ll prev = LLONG_MIN;
vector<ll> ans,trs;
for(auto x : ip){
if(x == prev+1){
trs.push_back(x);
}
else if(x == prev);
else trs.clear(),trs.push_back(x);
prev = x;
if(trs.size() > ans.size())ans = trs;
}
for(auto x : ans)cout << x << ' ';
}