0%

[題解]連號或不連號

a127. 連號或不連號

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define N 24
#define FOR(i,n) for(int i=0;i<n;i++)
using namespace std;
int n;

int main(){
while(cin>>n){
set<int>s;
for(int i=0;i<n;i++){
int x;cin>>x;
s.insert(x);
}
int maxn = *(--s.end());
int minn = *s.begin();
if(s.size()==maxn-minn+1)cout<<minn<<" "<<maxn<<" yes"<<endl;
else cout<<minn<<" "<<maxn<<" no"<<endl;
}
}