Code: Select all

```
1 2
Not Jolly
```

if n=1..then it should contain alll the differnece 1 to 0(1-1)..is'nt it!!!

so if n=1,the it will be jolly if the input is as follows..

Code: Select all

```
1 1
```

GOOD LUCK

Rocky

**Moderator:** Board moderators

Code: Select all

```
1 2
Not Jolly
```

if n=1..then it should contain alll the differnece 1 to 0(1-1)..is'nt it!!!

so if n=1,the it will be jolly if the input is as follows..

Code: Select all

```
1 1
```

GOOD LUCK

Rocky

the system always give me WA , i dont know why.

any ideas...

/*

PROGRAMMING CHALLENGES

The Programming Contest Training Manual

IBM

2.8 Problems

2.8.1 Jolly Jumpers

*/

#include <iostream>

#include <cstdlib>

#include <vector>

#include <list>

#include <cmath>

using namespace std;

int main()

{

vector<int> nums;

list<int> res;

int seq, num,result;

int num1,num2;

cin >> seq;

if(seq <= 0 || seq > 3000)

exit(0);

nums.reserve(seq);

//To store the input in nums

for(int i = 0 ;i < seq;i++)

{

cin >> num;

nums.push_back(num);

}

//to get the difference and store it in (res) vectore variable

vector<int>::iterator iter;

for(iter = nums.begin();iter != nums.end();iter++)

{

num1 = *iter;

iter++;

if(iter == nums.end())

break;

num2 = *iter;

iter--;

result = num1 - num2;

res.push_back(abs(result));//store the absolute value of result

}

res.sort();

res.unique();

for(int i = res.size();i > 0;i--)

{

--seq;

if(res.back() == seq)

{

res.pop_back();

}

else

{

cout << "Not jolly" << endl;

exit(1);

}

}

cout << "jolly" << endl;

return 0;

}

any ideas...

/*

PROGRAMMING CHALLENGES

The Programming Contest Training Manual

IBM

2.8 Problems

2.8.1 Jolly Jumpers

*/

#include <iostream>

#include <cstdlib>

#include <vector>

#include <list>

#include <cmath>

using namespace std;

int main()

{

vector<int> nums;

list<int> res;

int seq, num,result;

int num1,num2;

cin >> seq;

if(seq <= 0 || seq > 3000)

exit(0);

nums.reserve(seq);

//To store the input in nums

for(int i = 0 ;i < seq;i++)

{

cin >> num;

nums.push_back(num);

}

//to get the difference and store it in (res) vectore variable

vector<int>::iterator iter;

for(iter = nums.begin();iter != nums.end();iter++)

{

num1 = *iter;

iter++;

if(iter == nums.end())

break;

num2 = *iter;

iter--;

result = num1 - num2;

res.push_back(abs(result));//store the absolute value of result

}

res.sort();

res.unique();

for(int i = res.size();i > 0;i--)

{

--seq;

if(res.back() == seq)

{

res.pop_back();

}

else

{

cout << "Not jolly" << endl;

exit(1);

}

}

cout << "jolly" << endl;

return 0;

}

Last edited by azzo71 on Tue May 22, 2007 8:28 pm, edited 1 time in total.

- newton
- Experienced poster
**Posts:**162**Joined:**Thu Jul 13, 2006 7:07 am**Location:**Campus Area. Dhaka.Bangladesh-
**Contact:**

hi rocky

in the problem there is a comments....

so how

may u expalin please?

" i like logic "

in the problem there is a comments....

Code: Select all

```
The definition implies that any sequence of a single integer is a jolly jumper.
```

so how

Code: Select all

```
1 2
Not joly
```

may u expalin please?

" i like logic "

The answer is 'Joly' for 1 2. Rocky, read the description again.

Ami ekhono shopno dekhi...

HomePage

HomePage

- jainal cse du
- New poster
**Posts:**23**Joined:**Thu Jul 27, 2006 2:43 pm**Location:**University of Dhaka,Bangladesh

Last edited by jainal cse du on Mon Jun 04, 2007 11:46 am, edited 1 time in total.

- jainal cse du
- New poster
**Posts:**23**Joined:**Thu Jul 27, 2006 2:43 pm**Location:**University of Dhaka,Bangladesh

My AC program outputs:

[code]

Jolly

Not jolly

Not jolly

Jolly

Jolly

Not jolly

Jolly

Jolly

Jolly

Not jolly

Not jolly

Jolly

Jolly

Not jolly

Jolly

Not jolly

Jolly

[/code]

As for which one is correct, it all comes down to the following input:

[code]

1 2

[/code]

Since there is only one integer, shouldn't the correct output be "Jolly"?[/quote][quote]

why the third case " 10 1 2 3 4 5 6 7 8 9 10" Not jolly ?[/quote]