Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: SparkPun

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.003 second

Submitted On: 2025-11-04 19:26:14

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    set<int>s;
    vector<int>ans;
    while(cin >> n){
        s.insert(n);
    }
    for(auto x:s){
        if(!s.count(x-1)){
            vector<int>temp;
            int cur=x;
            while(s.count(cur)){
                temp.push_back(cur);
                cur++;
            }
            if(temp.size()>ans.size()){
                ans=temp;
            }
        }
    }
    for(auto x:ans){
        cout << x << " ";
    }
}