Submission

Status:

---PPPP-PP

Subtask/Task Score:

60/100

Score: 60

User: Kittiponn

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.003 second

Submitted On: 2026-03-04 10:50:23

#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);
    string n;
    while(1){
        cin >> n;
        if((n >= "a" && n <= "z") || (n >= "A" && n <= "Z"))break;
        int k = stoi(n);
        ip.insert(k);
    }
    int prev = -1000000;
    vector<int> ans,trs;
    for(auto x : ip){
        if(x == prev+1){
            trs.push_back(x);
        }
        else trs.clear(),trs.push_back(x);
        prev = x;
        if(trs.size() >= ans.size())ans = trs;
    }
    for(auto x : ans)cout << x << ' ';
}

/* #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;



int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> ip(n);
    for(auto &x:ip)cin >> x;
    for(int i = 0;i < n-1;i++){
        int idx = i;
        for(int j = i+1;j < n;j++){
            if(ip[j] < ip[idx])idx = j;
        }
        swap(ip[i],ip[idx]);
        for(auto &x : ip)cout << x << ' ';
        cnl;
    }
} */