Code Nation Online Assesment.
Anonymous User
1016

CODE NATION | NEW GRADUATE | INDIA

QUESTION1:

You are given 2 intersecting walls( functioning as X,Y and Z axes). You are given a number N. You have to place N cubes of dimensions 1x1x1 according to the following rules.

*Rules:

  1. A cube can be placed on top of another cube only when bottom cube is surrounded on 4 sides by other cubes.
  2. If bottom cube denoted by X is surrounded by a wall on 1 or 2 sides, rest of the 3 or 2 sides should be covered by placing cubes adjacent to it so that, we can place another cube on top of cube X.*

Find the minimum base area required to place all the cubes.

input:
1<=T<=10^6 (No of test cases)
1<=N<= 10^18 (No of cubes for each test case)

sample test case:

Input: T=1,N = 4
output: Min area = 3;

Explaination:
Place 1st cube at the intersection of 2 walls.
2 nd and 3rd cube on the other 2 unoccupied sides of 1st cube.
4th cube on top of 1st cube as 1st cube is now covered on both sides.
Base Area = 3(occupied by 1st,2nd and 3rd cubes).

Question 2:
A country X is attacking another country Y with an initial missile strength of Y on Day zero(0). This carries out a chain reaction.
Each city in country Y has a strength , city i has strength arr[i].
Those cities are destroyed on 0th day whose strength is less than Y.
On i th day after zeroth day,the strength of those cities which are at a distance i from the cities destroyed on 0th day, decreases by Y. You are given a number D (no of days). All the cities must be destroyed on or before Dth day.
Find the minimum possible value of Y(initial missile strength) so that all the cities get destroyed within D days.

input: N,D
N = no of cities, D = no of days.
Next line contains N integers, denoting strengths of cities.

1<=N<=10^6
1<=D<=10^5
1<=arr[i]<=10^9 (arr[i] = strength of ith city)

3rd question can be found here:
https://imgur.com/a/6pzLsWC

Thanks to @grimjaw for providing with a link to the third question.

Comments (9)