Submission

Status:
PPPPPPPPPP

Score: 100

User: Nathlol2

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-15 21:36:39

#include <bits/stdc++.h>
using namespace std;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    vector<int> a;
    int x;
    while(cin >> s){
        try{
            x = stoi(s);
            a.push_back(x);
        }catch(...){
            break;
        }
    }
    int n = a.size();
    map<int, int> num;
    for(int i = 0;i<n;i++){
        num[a[i]]++;
    }
    int mx = -1, start;
    for(auto it = num.begin();it != num.end();it++){
        int m = 1;
        int cur = it->first;
        while(num.find(cur + 1) != num.end()){
            m++;
            cur++;  
        }
        if(m > mx){
            mx = m;
            start = it->first;
        }
    }
    for(int i = 0;i<mx;i++){
        cout << i + start << " ";
    }
}