Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 3.14 KB

codegladiators-2022.md

File metadata and controls

83 lines (63 loc) · 3.14 KB

Techgig-Code Gladiators 2022

World Army vs Aliens

WorldArmyAliens.java

The world is going to be attacked by the aliens. The space intelligence department has raised an alarm and the world armies are coming together to fight them. The planning and strategizing is being done to make the maximum impact on the alien ships. The deadly missiles are to be put into action. The missiles are targeted to destroy the alien ships in space and disable them to land on the Earth.

The army is planning to launch the attack at A time (hh mm) to get an advantage. For each attack, they know the time the missile will require to hit the coming alien ship. They all are busy in preparation and want to know the time at which the blast will occur and the alien ship will be destroyed in pieces. Can you find the time of the blast ?

Note: The World Army follows a 24-hour time format and you need to find the time of blast accordingly. The time will be in the hh mm format.

Example:
Input Format

The first line of input consists of the launch time in hh mm format separated by space.
The second line of input consists of the travel time for the missile in hh mm format separated by space.

Constraints
00<= hh <=23
00<= mm <=59

Output Format
Print the time at which the blast will occur and the spaceship will be destroyed.

Sample TestCase 1
Input
19 50
02 20
Output
22 10

Chantu Bantu

ChantuBantu.java

Chantu and Bantu are the hostlers and like any other hostler have very less money with them. They promised their girlfriends, Rani and Sheena that they would give them N number of gifts on their birthday. The birthday is next week and Chantu and Bantu are trying to figure out a way to make them happy.

They went to a gift shop which consists of G number of gifts and now need your help to determine the minimum money they will have to arrange to buy N gifts. Once you tell them the amount of money required, they will plan out something to arrange for the money. Can you help them figure out the minimum money required to buy N gifts?

Example:
Number of gifts available in the shop, G = 8
Number of gifts to be bought, N = 3
The minimum amount of money Chantu Bantu have to spend to buy 3 gifts = 10 + 20 + 30 = 60

Input Format
The first line of input consists of number of test cases, T
The first line of each test case consists of number of gifts Chantu Bantu have to buy, N
The second line of each test case consists of number of gifts available in the shop, G
The thirds line of each test case consists of G space-separated integers representing the price of G gifts where the first integer represents the price of first gift and so on.

Constraints
1<= T <=10
1<= G <=100000
1<= N <=G
0<= Price of Gift <=10000000

Output Format
For each test case, print the minimum amount of money Chantu Bantu has to pay to buy the N gifts.

Sample TestCase 1
Input
2
3
8
50 70 30 100 80 20 150 10
4
6
10 20 32 412 500 11
Output
60
73
Explanation

Test Case 1: As explained in the example.
Test Case 2:
Number of gifts to be bought, N = 4
Number of gifts available, G = 6
Minimum amount of money Chantu Bantu has to pay = 10 + 20 + 32 + 11 = 73