Submission
Status:
---PP---PP
Subtask/Task Score:
40/100
Score: 40
User: navysrimuang
Problemset: Consecutive Subsequence
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-15 13:52:47
#include<bits/stdc++.h>
using namespace std;
bool numb(string s){
for(char c : s) if(!isdigit(c)) return 0;
return s.size();
}
int main(){
unordered_set<int> st;
while(true){
string s; cin >> s;
if(!numb(s)) 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;
}