Submission
Status:
----------
Subtask/Task Score:
0/100
Score: 0
User: Kittiponn
Problemset: Consecutive Subsequence
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-04 10:38:49
#include <bits/stdc++.h>
#define ll long long
#define sp << ' ' <<
#define nl << '\n'
#define cnl cout << '\n'
using namespace std;
const int nx = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;
vector<int> ip;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n;
while(cin >> n){
ip.push_back(n);
}
sort(ip.begin(),ip.end());
int prev = -1000000;
vector<int> ans,trs;
for(auto x : ip){
if(x == prev+1){
trs.push_back(x);
}
else trs.clear(),trs.push_back(x);
prev = x;
if(trs.size() >= ans.size())ans = trs;
}
for(auto x : ans)cout << x << ' ';
}
/* #include <bits/stdc++.h>
#define ll long long
#define sp << ' ' <<
#define nl << '\n'
#define cnl cout << '\n'
using namespace std;
const int nx = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<int> ip(n);
for(auto &x:ip)cin >> x;
for(int i = 0;i < n-1;i++){
int idx = i;
for(int j = i+1;j < n;j++){
if(ip[j] < ip[idx])idx = j;
}
swap(ip[i],ip[idx]);
for(auto &x : ip)cout << x << ' ';
cnl;
}
} */