Submission

Status:
----------

Score: 0

User: Nathlol2

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.003 second

Submitted On: 2025-03-15 20:31:51

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

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

    string s;
    vector<int> a;
    while(cin >> s){
        stringstream ss(s);
        int n;
        if(ss >> n && ss.eof()){
            a.push_back(n);
        }else{
            break;
        }
    }
    int n = a.size();
    vector<int> ans;
    vector<int> p;
    int m = 1, ms = 0;
    for(int i = 1;i<n;i++){
        if(p.size() == 0){
            p.push_back(a[i - 1]);
        }
        if(a[i] == a[i - 1] + 1){
            m++;
            p.push_back(a[i]);
            if(m > ms){
                ms = m;
                ans = p;
            }
        }else{
            m = 1;
            p.clear();
        }
    }
    for(auto i : ans){
        cout << i << " ";
    }
}