#27819: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

School : 臺北市立和平高級中學
ID : 163096
IP address : [203.72.60.244]
Last Login :
2022-03-11 16:00:13
c299. 1. 連號或不連號 -- 106學年度全國資訊學科能力競賽 | From: [219.85.1.131] | Post Date : 2021-10-31 01:15

#include <iostream>
using namespace std;

int main(){
int n;
while (cin >> n){
int g[1001]={0};
int mx=0;
int mn=1001;
for (int i=0, x; i<n; i++){
cin >> x;
g[x]=1;
mx=max(mx, x);
mn=min(mn, x);
}
int sum=0;
for (int i=mn; i<=mx; i++){
sum+=g[i];
}
if (sum==mx-mn+1){
cout << mn <<" "<< mx <<" yes"<<endl;
}
else {
cout << mn <<" "<< mx <<" no"<<endl;
}
}
return 0;
}
 
ZeroJudge Forum