jerseyguy's blog

By jerseyguy, history, 17 months ago, In English

problem statement :
given n students and m colleges
each student has a list of preferred colleges in which they want to take admission.
each college has a certain capacity to take students
assuming any college will accept any student
find a mapping such that max number of students can get admission and return max number of seats that can be occupied.

note: constraints were not given and students will take admission if they get a seat in their preferred college

Full text and comments »

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

By jerseyguy, history, 18 months ago, In English

question :

Given n cities and m roads b/w them. Each road is represented as [L,R,X] L is the starting city, R — the ending city, and X the cost.
Also for all roads L<R . If there is a road from city L to R with cost X then one can travel b/w any two cities that lie b/w L and R(inclusive) with cost X.

Find the minimum cost to travel from 1 to N.

T<=10
N,M <= 1e5
L,R<=N
X<=1e6

My approach : sorting and priority queue , but it gave WA

sample:
2
4 1
1 3 10
4 3
1 4 10
1 2 5
2 4 3

op:
-1
8

Full text and comments »

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

By jerseyguy, history, 2 years ago, In English

You are given an old touch smartphone numbers having dial pad and calculator app.

Aim: The goal is to type a number on dialpad.

But as phone is old, some of the numbers and some operations can't be touched. For eg. 2,3,5,9 keys are not responding , i.e you cannot use them But you can always make a number using other numbers and operations in Calculator. There could be multiple ways of making a number

.Calculator have 1-9 and +,-,*,/,= as operations. Once you have made the number in Calculator you can copy the number and use it.

You have to find minimum number to touches required to obtain a number.

Input:

There will be multiple Test cases .Each test case will consist of 4 lines 1) First line will consist of N,M,O N: no of keys working in Dialpad (out of 0,1,2,3,4,5,6,7,8,9) M:types of operations supported (+,-,*,/) O: Max no of touches allowed

2) second line of input contains the digits that are working e.g 0,2,3,4,6. 3) Third line contains the valued describing operations, 1(+),2(-),3(*),4(/)

4) fourth line contains the number that we want to make .

Output:

Output contains 1 line printing the number of touches required to make the number

Sample Test Case:

1 // No of test cases 5 3 5 // N ,M, O 1 2 4 6 0 // digits that are working (total number of digits = N), 1 2 3 // describing operations allowed (1--> '+', 2--> '-', 3--> '*' , 4--> '/' )(total number is equals to M) 5 // number we want to make

Answer 3 How 4? 1+4= , "=" is also counted as a touch

2nd Sample Case 3 // No of Test cases 6 4 5 // N ,M, O 1 2 4 6 9 8 // digits that are working (total number of digits = N), 1 2 3 4 // describing operations allowed (1--> +, 2--> -, 3--> , 4-->/) 91 // number we want to make 6 2 4 // 2nd test case 0 1 3 5 7 9 1 2 4 // +, -, / allowed here 28 5 2 10 1 2 6 7 8 2 3 // -, allowed 981

Output:

2 // 91 can be made by directly entering 91 as 1,9 digits are working, so only 2 operations 5// 35-7=, other ways are 1+3*7= 9//62*16-11=

Order for computation will be followed as symbols entered, if + comes, it will be computed first

One more example: lets say 1,4,6,7,8,9 works and +,-,* works. 2,3,5 and / doesn't work. If you have to type 18-> 2 operations. (Each touch is considered an operation),br> If you have to type 5 -> '1+4=' that requires 4 operations. There could be other ways to make '5'.

Full text and comments »

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

By jerseyguy, history, 2 years ago, In English

Can someone give some suggestion , caught in 1400 — 1500 rating range

Full text and comments »

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

By jerseyguy, history, 3 years ago, In English

Can someone give some hints to this problem from cf edu. Problem : D. Minimum maximum on the Path

Regards.

Full text and comments »

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

By jerseyguy, history, 3 years ago, In English

Can somebody give some hints? problem name : students council ( from cf edu section)

Regards.

Full text and comments »

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