Jolly Jumpers
題目:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
#include <bits/c++.h>
using namespace std;
int main()
{
while(true){
int case_number;
int temp;
int Jelly=0;
vector<int> input_list;
vector<int> count_list;
cin>>case_number;
for (int i=0;i<case_number;i++){
cin>>temp;
input_list.push_back(temp);
temp=0;
}
//sort(input_list.rbegin(),input_list.rend());
for (int i=0;i<case_number-1;i++){
count_list.push_back(abs(input_list[i+1]-input_list[i]));
}
sort(count_list.rbegin(),count_list.rend());
for (int i=0;i<case_number-1;i++){
if(count_list[i]-count_list[i+1]==1){
Jelly = 1;
}
else{
Jelly = 0;
break;
}
}
if(Jelly==1&&count_list.size()==case_number-1){
cout<<"Jolly"<<endl;
}
else{
cout<<"Not jolly"<<endl;
}
}
}