Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: havename

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-07 08:21:33

#include<bits/stdc++.h>
using namespace std;
int main(){
    map<int,int> mp;
    string s;
    while(cin>>s){
        if(isalpha(s[0])) break;
        int a=stoi(s);
        mp[a]=1;
    }
    int lt=-1e9+7;
    int cur=0,mx=0;

    int st=0,bt=0;

    for(auto x:mp){
        int num=x.first;
        if(num==lt+1){
            cur++;
        }
        else{
            cur=1;
            st=num;
        }
        if(cur>mx){
            mx=cur;
            bt=st;
        }
        lt=num;
    }
    
    for(int i=0;i<mx;i++){
        cout << bt + i << " ";
    }
}