~cpp
#include<iostream>
using namespace std;
int* InputList();
bool Judge(int* aList);
void OutputJudgement(bool aIsIt);
int GetSumOfGoalGap(int aN);
bool isCorrectInput;
void main()
{
isCorrectInput = true;
OutputJudgement(Judge(InputList()));
}
int* InputList(){
bool isInputStart = false;
int numberOfInputFactor;
int* inputedList;
do{
if(!isInputStart){
if(cin >> numberOfInputFactor){
inputedList = new int[numberOfInputFactor+1];
inputedList[0] = numberOfInputFactor;
isInputStart = true;
if(numberOfInputFactor < 2){
isCorrectInput = false;
numberOfInputFactor = 0;
}
}
else{
isCorrectInput = false;
numberOfInputFactor = 0;
}
}
else{
if(!(cin >> inputedList[inputedList[0] - numberOfInputFactor])){
isCorrectInput = false;
numberOfInputFactor = 0;
}
}
numberOfInputFactor--;
}while(numberOfInputFactor >= 0);
char temp;
cin.get(temp);
if(temp != '\n')
isCorrectInput = false;
return inputedList;
}
bool Judge(int* aList)
{
if(!isCorrectInput)
return false;
int gap;
bool* binaryMap = new bool[aList[0]-1];
for(int i = 0; i < aList[0]-1; i++)
binaryMap[i] = false;
for(i = 1; i < aList[0]; i++){
gap = abs(aList[i] - aList[i+1]);
if(gap >= aList[0] || gap == 0 || binaryMap[gap-1]){
delete aList;
delete binaryMap;
return false;
}
else
binaryMap[gap-1] = true;
}
delete aList;
delete binaryMap;
return true;
}
void OutputJudgement(bool aIsIt)
{
if(aIsIt)
cout << "JollyJumpers\n";
else
cout << "Nothing\n";
}
각 ¶
(performance) 기 각 .
2
1. gap 각기 기.(ex)2 .)
간 : Ο(n)
2
1. gap 각기 기.(ex)2 .)
- binaryMap bool gap
간 : Ο(n)










