This is an Editorial for GMSTRE - Game Store problem in SPOJ

This is adhoc problem............

This is adhoc problem............

This day is a very special day, especially for all gamers around the
world. The clock now is showing at 8 am and the queue in front of the
game store is getting crazy. It is like a hundred of people standing in a
line waiting for something big. Then what is that ? Yes, of course the
people are going to buy the very new game, just released yesterday. It
is the first first-person shooting (FPS) game with very incredible
price. Brembo, one of the skillfull FPS gamers, of course he doesn't
want to miss this. He also buys the game and then plays the game.

After one hour playing the games, Brembo feels that the game is very difficult, but sometimes is very easy. He doesn't feel good about that, and decided to replay the game from the beginning. However, now he wants to play the game in more balanced ways. He first plays the easy-difficulty levels and then go harder until the he reaches the hardest-difficulty level. Poor Brembo, he finds out that the levels are placed randomly and gets confused on choosing the levels.

You as his friends, called by Brembo to help him out. There are N levels in the game. Basically, in every level you are given the information about some specific elements. You will notice the bar under the map's levels that contain the information. First, is the number of Health Pack that will be placed in a level. Second, is the number of enemies in a level. And third, is the number of ammo available in a level. A level is said to be easier than another level if it has more Health Pack, less enemies, and more ammo.

Now, you are about to analyze the situation based on the description above. Given the information of N levels, find the easiest and the hardest level based on the information. Since you are Brembo's best friend, you don't want to make him disappointed and you will help him.

The next N lines contain three integers separated by space Hi, Ei, Ai, represent the number of Health Pack, enemies, and ammo for i-th level. ( 1 <= Hi,Ei,Ai <= 10000)

It is guaranteed that every level has different information.

First line : "Easiest is level a" (a for the level number)

Second Line : "Hardest is level b" (b for the level number)

Print them without quotes.

After one hour playing the games, Brembo feels that the game is very difficult, but sometimes is very easy. He doesn't feel good about that, and decided to replay the game from the beginning. However, now he wants to play the game in more balanced ways. He first plays the easy-difficulty levels and then go harder until the he reaches the hardest-difficulty level. Poor Brembo, he finds out that the levels are placed randomly and gets confused on choosing the levels.

You as his friends, called by Brembo to help him out. There are N levels in the game. Basically, in every level you are given the information about some specific elements. You will notice the bar under the map's levels that contain the information. First, is the number of Health Pack that will be placed in a level. Second, is the number of enemies in a level. And third, is the number of ammo available in a level. A level is said to be easier than another level if it has more Health Pack, less enemies, and more ammo.

Now, you are about to analyze the situation based on the description above. Given the information of N levels, find the easiest and the hardest level based on the information. Since you are Brembo's best friend, you don't want to make him disappointed and you will help him.

### Input

The first line of input is N, the number of levels in the game. (1 <= N <= 100)The next N lines contain three integers separated by space Hi, Ei, Ai, represent the number of Health Pack, enemies, and ammo for i-th level. ( 1 <= Hi,Ei,Ai <= 10000)

It is guaranteed that every level has different information.

### Output

The output contain two lines or one line if there is only one level.First line : "Easiest is level a" (a for the level number)

Second Line : "Hardest is level b" (b for the level number)

Print them without quotes.

### Example 1

Input:4 3 2 3 3 4 1 1 4 5 2 2 2Output:Easiest is level 1 Hardest is level 3

### Example 2

Input:1 2 3 1Output:Easiest and Hardest is level 1

The link for this problem is:

#### http://www.spoj.com/problems/GMSTRE/

Here comes the solutions the things we must keep in mind while find the solution are :

#### Approach:

A level is said to be easiest Health Pack, less enemies, and more ammo.

So First in writing the solution:

1) Find a level with maximum Health Pack.

2)In this cases if multiple levels has same Health Pack of maximum values then check for enemies with least value among maximum Health pack levels.

Example :suppose the levels in query are 2 4 5 and 2 6 7

we now have same health packs for both so now we must compare enemies since in second level in above example have less enemies so 2 4 5 is easiest level.

3)In this cases if multiple levels has same Health Pack of maximum value and

with enemies have same value in both health pack maximum levels we must now go to ammo comparison.

Go for level Which have maximum ammo's in all possible cases with same maximum health and same enemies.

Example :suppose 2 4 5 and 2 4 7 are given levels we must now have same health pack values and same enemies.So we must choose the level with maximum ammos or ammo value.So 2 4 7 is our easiest level in the given input.

Similarly, for finding the hardest level we must take reverse conditions that are taken in easiest level process this can be more understandable in solution of the

problem.

#### Note:

1) Incase if the given 'n' or number levels is '1' then we must have to print the output as

#### Easiest and Hardest is level 1

2) In all other cases you must print like as shown in example below keep in mind that in output printing there must be black line at the otherwise it will leads to wrong answer.

#### Easiest is level 1

#### Hardest is level 3

The CPP solution for above problem is:

```
#include <iostream>
using namespace std;
int main(void) {
//a is an array that takes input levels
//min1,min2,min3 are used to store easy level values and lv1 is easy level
//max1,max2,max3 are used to store hard level values and lv2 is hard level
long int a[1002][3],n,i,j,k,min1,min2,min3,max1,max2,max3,lv1,lv2;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i][0]>>a[i][1];
cin>>a[i][2];
}
if(n>1)
{
//From here our logic is implemented as discussed above
min1=a[0][0];
min2=a[0][1];
min3=a[0][2];
lv1=1;
lv2=1;
max1=a[0][0];
max2=a[0][1];
max3=a[0][2];
for(i=0;i<n;i++)
{
if(min1>a[i][0])
{
min1=a[i][0];
min2=a[i][1];
min3=a[i][2];
lv1=i+1;
}
else if(min1==a[i][0]&&min2<a[i][1])
{
min1=a[i][0];
min2=a[i][1];
min3=a[i][2];
lv1=i+1;
}
else if(min1==a[i][0]&&min2==a[i][1]&&min3>a[i][2])
{
min1=a[i][0];
min2=a[i][1];
min3=a[i][2];
lv1=i+1;
}
}
for(i=0;i<n;i++)
{
if(max1<a[i][0])
{
max1=a[i][0];
max2=a[i][1];
max3=a[i][2];
lv2=i+1;
}
else if(max1==a[i][0]&&max2>a[i][1])
{
max1=a[i][0];
max2=a[i][1];
max3=a[i][2];
lv2=i+1;
}
else if(max1==a[i][0]&&max2==a[i][1]&&max3<a[i][2])
{
max1=a[i][0];
max2=a[i][1];
max3=a[i][2];
lv2=i+1;
}
}
cout<<"Easiest is level "<<lv2<<endl;
cout<<"Hardest is level "<<lv1<<endl;
}
else
{
cout<<"Easiest and Hardest is level 1"<<endl;
}
cout<<endl;
return 0;
}
```

## No comments:

## Post a comment