-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgood_vector.cpp
More file actions
52 lines (46 loc) · 868 Bytes
/
good_vector.cpp
File metadata and controls
52 lines (46 loc) · 868 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
#include <stdc++.h>
using namespace std;
bool sorted(vector<int> &nums)
{
cout<<endl<<"your are in sorted"<<endl;
for (int i = 0; i < nums.size() ; i++)
{
cout<<nums.at(i)<<" ";
}
for (int i = 0; i < nums.size() - 2 ; i++)
{
if (nums.at(i+1) - nums.at(i) != 1)
{
return false;
}
}
return true;
}
bool isGood(vector<int> &nums)
{
sort(nums.begin(), nums.end());
int k = nums.size() - 1;
// cout<<nums.at(k)<<" " <<nums.at(k - 1)<<endl;
if (sorted(nums))
{
return true;
}
cout<<"what"<<endl;
return false;
}
int main()
{
vector<int> v;
int a, x;
cin >> a;
for (int i = 0; i < a; i++)
{
cin >> x;
v.push_back(x);
}
if (isGood(v))
{
cout << "OK" << endl;
}
return 0;
}