Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: colo39

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.003 second

Submitted On: 2026-11-28 13:35:09

#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
vector<int> hold;
map<int,int> mp;
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    while (1) {
        string c;
        cin >> c;
        if (c.size() == 1) {
            if (!isdigit(c[0])) break;
        }
        int n = stoi(c);
        mp[n] = 1;
    }
    for (auto &x :mp) {
        if (x.second == 1) {
            if (hold.size() == 0) {
                hold.push_back(x.first);
            } else {
                if (hold.back()+1 == x.first) {
                    hold.push_back(x.first);
                    if (ans.size() < hold.size()) ans = hold;
                } else {
                    hold.clear();
                    hold.push_back(x.first);
                }
            }
        }
    }
    for (auto &x : ans) cout << x << " "; 
    return 0;
}