Submission
Status:
P--PPPPPPP
Subtask/Task Score:
80/100
Score: 80
User: navysrimuang
Problemset: Consecutive Subsequence
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-15 13:49:06
#include<bits/stdc++.h>
using namespace std;
int main(){
unordered_set<int> st;
while(true){
string s; cin >> s;
if(s.size() == 1 && (s[0] < 48 || s[0] > 57 )) break;
int x = stoi(s);
st.insert(x);
}
int mx = 1;
pair<int,int> ans;
for(int x : st){
if(!st.count(x-1)){
int ss = x;
int cnt = 1;
while(st.count(x+1)){
cnt++;
x++;
}
int ee = x;
if(cnt > mx){
mx = cnt;
ans = {ss,ee};
}
}
}
for(int i = ans.first; i <= ans.second;i++) cout << i << " ";
return 0;
}