-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12.cpp
More file actions
59 lines (52 loc) · 863 Bytes
/
12.cpp
File metadata and controls
59 lines (52 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
string input;
int idx = 0;
int start = 0;
int _long = 1;
int max_start = 0;
int max_long = 1;
int list[10] = {0};
getline(cin,input);
for(int i=0; i<input.size(); i++) {
if(input[i] == ' ') {
idx++;
continue;
}
list[idx] = list[idx]*10 + (input[i] - '0');
}
for(int i=0; i<=idx; i++) {
for(int j=i+1; j<=idx; j++) {
if(list[i] > list[j])
{
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
}
for(int i=1; i<=idx; i++) {
if(list[i]-list[i-1] == 1) {
_long++;
if(idx >= max_long)
{
max_start = start;
max_long = _long;
}
}
else {
start = i;
_long = 1;
}
}
for(int i=0; i<max_long; i++) {
cout << list[i+max_start] << " ";
}
cout<<endl;
return 0;
}