GMSTRE - Game Store
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 follows these priority, 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 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.
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.
Input: 4 3 2 3 3 4 1 1 4 5 2 2 2 Output: Easiest is level 1 Hardest is level 3
Input: 1 2 3 1 Output: Easiest and Hardest is level 1
vector of tuples, custom sort, AC
no need to use lots of IF-ELSE just sort wisely :)
Test cast 19 in SPOJ ToolKit
check in order - health,enemies,ammo. sorting and then for loops with lots of if else ;)
The description of the problem is misleading -- "A level is said to be easier than another level if it has more Health Pack, less enemies, and more ammo." clearly suggest that ALL three conditions must be met to consider a level easier, whereas the correct solution must check for health packs only first, in case of tie to check for enemies, and then for ammo as a last resort.
I think the right tag for this problem is greedy and not just the adhoc
@wisfaq I agree with you and it's quite confusing if you think about them before solving it
Last edit: 2018-03-28 17:39:16