U E D R , A S I H C RSS

Jolly Jumpers/Celfin

~cpp
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int testcase, preNum, currentNum, i;
char temp[50000];

vector<int> numList;

int main()
{
	while(cin>>testcase)
	{
		if(testcase==0 || testcase==1)
		{
			cin>>preNum;
			cout <<"Jolly"<<endl;
		}
		else
		{
			cin>>preNum;
			for(i=1; i<testcase; i++)
			{
				cin >> currentNum;
				numList.push_back(abs(currentNum-preNum));
				preNum = currentNum;
			}
			cin.getline(temp, 50000);
			sort(&numList[0], &numList[numList.size()]);
			for(i=0; i<testcase-1; i++)
			{
				if(numList[i]!=i+1)
				{
					cout <<"Not jolly"<<endl;
					break;
				}
				if(i==testcase-2)
					cout <<"Jolly"<<endl;
			}
			for(i=0; i<numList.size(); i++)
				numList.erase(numList.begin()+i);
			numList.clear();
		}
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:34
Processing time 0.0112 sec