wizard_18's blog

By wizard_18, history, 5 years ago, In English

1) Virat is looking to book hotel rooms for an incoming delegation of engineers. She is Allowed to spend anywhere between B Rupees and C Rupees (Both Inclusive). She needs to book rooms consecutively as delegates would prefer to stay as close as possible.

Virat as been given the pricing of the rooms in the form of a array (A). You need to help virat to find the total no of options available to book like this in the given range.

Note- There is no restriction in no of rooms he can book.( Min 1 or Max Size of the array)

Input Format

First Line contains 3 Integers N,B,c where N is the Size of the array.

Second Line contains N integers denoting the price of t=each rooms available.

Output format

Total No of possible option available for to book the rooms.

Constraints

1 <= N,B,C <= 10^6

Sample Input 0

5 6 8

10 5 1 0 2

Sample Output 0

3

Explanation

[5,1],[5,1,0],[5,1,0,1] are only 3 consecutive options available within the price sum range.

2)We are given an array 'a' of 'N' non-negative elements (eg a1,a2...aN). We can take any two consecutive elements of an array and reduce it by value 1, we can perform this operation as many numbers of times.

We are also given an array 'b' of 'N' non-negative elements (eg b1,b2...bN).It is also made sure that b[i]<=a[i].

Print 'YES' if it is possible to convert array 'a' to array 'b' by using the above operation as many numbers of times. If it is not possible then print 'NO'.

Constraints

1<=N<=1000

0<=A[i]<=10^9

0<=B[i]<=10^9

Input Format

The first line contains T the number of Test Cases.

The second line contains N, No of elements in the array

The Next line contains N space separated positive integers (A1 through An) :

The Next line contains N space separated positive integers (B1 through Bn) :

Output Format

For each test case output YES or NO

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

By wizard_18, history, 5 years ago, In English

Link of the question There are N countries. The ith country has A[i] number of players. You want to create new teams such that : 1. No two members from the same team are from the same country i.e. every member from a team should be from a different country 2. Teams should be exactly of size K Your task is to write a program to calculate the maximum number of teams that can be made. Input First line contains two integers N and K Second line contains N integers, denoting the number of players from each country Output Print one number equal to the maximum number of teams that can be made Notes 1 ≤ N, K ≤ 200 All values of A[i] fit in 32-bit integers. Sample Input 0 4 3 2 4 3 6 Sample Output 0 4

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By wizard_18, history, 5 years ago, In English
  • Vote: I like it
  • -7
  • Vote: I do not like it