Submission

Status:

---PPPP-PP

Subtask/Task Score:

60/100

Score: 60

User: Kittiponn

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-04 10:21:54

#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;
set<int> ip;


int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n;
    while(cin >> n){
        ip.insert(n);
    }
    int prev = *ip.begin();
    vector<int> ans,trs;
    for(auto x : ip){
        if(x == prev+1 || x == prev){
            trs.push_back(x);
            //cout << 'x';
        }
        else trs.clear();//cout << 'y';
        prev = x;
        if(trs.size() >= ans.size())ans = trs;
    }
    cout << ans.front()-1 << ' ';
    for(auto x : ans)cout << x << ' ';
}