chauhanshivam079's blog

By chauhanshivam079, history, 2 years ago, In English

There are N fighters numbered from 1 to N. Each fighter has strength and experience levels. The strength of the ith fighter is A[i] and experience level of ith fighter is B[i].

The fighters want to choose worthy opponents. Thus, the same opponent can be chosen for one or more fighter or can be not chosen at all. It is given that each fighter has to choose at most one opponent.

The ith fighter will choose an opponent with index j such that the following conditions are satisfied (if such opponent exists) • j<i • A[j] <A[i] • B[j] <B[i] The value of competition is defined as sum of experience levels of chosen opponents. Find the maximum possible value of competition modulo 10^9+7.

How will we solve this Question

Full text and comments »

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

By chauhanshivam079, history, 2 years ago, In English

You are given a 2D array arr of size N x M . In one operation you can either decrease or increase any element of arr by 1. Find the minimum number of operations needed to make every row and column of arr a palindrome, Note: A sequence B of size K is a palindrome if Bli] = B[K-i-1] for 0 <= i<k Input Format The first line contains an integer, N, denoting the number of rows in arr. The next line contains an integer, M, denoting the number of columns in arr Each line i of the N subsequent lines (where 0 si < N) contains M space separated integers each describing the row arr[i].

How will we solve this Question

Full text and comments »

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

By chauhanshivam079, history, 2 years ago, In English

Given n and 2 arrays a[i] denoting the time taken to eat ith grape and and b[i] denoting the power gained by eating the ith grape repectively. The total time to eat is T minutes. You can eat one grape irrespective of how many minutes it needs in usual time during the Tth minute of consumption. Find the max power that can be obtained in T minutes. N<=3000 T<=3000 1<A[i],b[i]<=3000

sample tc: n=2 T=60 a[i]={10,100} b[i]={10,100} output : 110 explanation: We can eat the 1 grape in first 10 miniutes.Then in the next 10 minute he can eat the second grape . power=10+100=110.

tc:2 n=2 T=60 a[i]={100,100} b[i]={100,100} output : 100 Explanation: Only one grape can be consumed.After that T minutes get over.. plz explain how to solve this question..I think dp would be used here...but i am not sure..

Full text and comments »

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