Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: devilpoohs

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.003 second

Submitted On: 2026-03-09 17:27:19

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    stack<int> st;
    string s;
    vector<int> ans;
    int mx=1;
    map<int,int> mp;
    while(true){
        cin>>s;
        if((s[0]>='a' and s[0]<='z') or (s[0]>='A' and s[0]<'Z')) break;
        mp[stoi(s)]=1;
    }
    int mxnum;
    int temp=-INT_MAX;
    int cnt=0;
    for(auto& i:mp){
        
        if(temp+1==i.first){
            cnt++;
        }else cnt=0;

        if(cnt>mx){
            mx=cnt;
            mxnum=i.first;
        }
        temp=i.first;
        // cout<<i.first<<' ';
    }
    for(int i=mxnum-mx;i<=mxnum;i++){
        cout<<i<<' ';
    }
    return 0;
}