bansal1232's blog

By bansal1232, history, 5 months ago, In English,

Can someone tell me how to approach this problem?

You are given N tasks with following information:

Deadline: Di

Reward: Ri

Time taken to complete the tasks: Pi

The reward is given only when a task is completed within the corresponding deadline.

Write a program to schedule the tasks in order to maximise the reward.

Input format

First line: T (number of test cases)
First line in each test case: N
Next N lines in each test case: Three space-separated integers Di, Ri, and Pi

Output format

For each test case, print the schedule of tasks that maximizes the reward in new line.

Constraints

1≤T≤10

1≤N≤103

1≤D≤103

1≤PD

1≤R≤106

Sample Input

1
6
1 2 1
2 3 1
4 1 2
10 10 10
15 13 10
15 7 5

Sample Output

20

Explanation

If we perform the last two task alone we can get the maximum reward which is 20

Read more »

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

By bansal1232, history, 6 months ago, In English,

Can someone please provide the editorial of this question.

You are given with integers a, b, c, d, m. These represent the modular equation of a curve y2 mod m = (ax3 + bx2 + cx + d) mod m

Also, you are provided with an array A of size N. Now, your task is to find the number of pairs in the array that satisfy the given modular equation.

If (Ai, Aj) is a pair then Aj2 mod m = (aAi3 + bAi2 + cAi + d) mod m.

Since the answer could be very large output it modulo 109 + 7.

Note: A pair is counted different from some other pair if either Ai of the two pairs is different or Aj of the two pairs is different. Also for the convenience of calculations, we may count (Ai, Aj) as a valid pair if it satisfies given constraints.

Input Format

First line of the input contains number of test cases T. First line for each test case consists of 5 space-separated integers a, b, c, d, m, corresponding to modular equation given. Next line contains a single integer N. Next line contains space-separated integers corresponding to values of array A.

Output Format

For each test case, output a single line corresponding to number of valid pairs in the array mod 109 + 7.

Constraints

1 ≤ T ≤ 10,  1 ≤ N ≤ 105,   - 2 × 109 ≤ a, b, c, d, Ai ≤ 2 × 109,  1 ≤ m ≤ 2 × 109

Sample Input

1
2 1 -1 3 5
5
10 2 3 14 12

Sample Output

2

Explanation

Equation of curve: y2 = 2x3 + x2 - x + 3 and m = 5. Valid pairs satisfying equation of line are (x, y) = (2, 14) and (12, 14). Therefore, the answer is 2.

Note: This question is taken from Hackerearth Lenskart hiring challenge which has already expired.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By bansal1232, history, 13 months ago, In English,

Codechef-Crawler

While doing lots of Competitive programming, I decided to contribute for open source. After doing lots of research I thought why not I start with codechef. Therefore, I make my own tool in Python which is completely open-source.

Codechef-Crawler is a tool to download all your code submission from codechef.com and store them locally with a well-structured manner. Please refer below link to know more about its usage.

Github: https://github.com/bansal1232/Codechef-Crawler

Features

  1. Download all solutions from Practise and Contest section of codechef.
  2. Solutions are downloading by using Multithreading concept which makes it faster to download in parallel way.
  3. Open-source
  4. It's Cross-platform which makes it to execute in any operating system.

Screeshots:

Credits

Used idea from https://github.com/koldbyte/CodeBackup

Contribute

If you have found a bug or have an feature request, feel free to fork and code it. And don't forget to send pull requests.

Thanks!

Read more »

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

By bansal1232, history, 2 years ago, In English,

Can someone tell me how to approach this problem for N = 1000, 000, 000 ?

Read more »

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

By bansal1232, history, 2 years ago, In English,

What's the right approach of solving this Hackerearth Problem?

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it