gjaiswal108's blog

By gjaiswal108, history, 4 years ago, In English

How to solve this problem ?

Given two arrays A[] and B[] of length N, the task is to find the minimum number of operations in which the array A can be converted into array B where each operation consists of adding any integer K into a subarray from L to R.

Source: https://www.geeksforgeeks.org/minimum-number-of-operations-to-convert-array-a-to-array-b-by-adding-an-integer-into-a-subarray/

PS: I came across this problem on gfg, but then realised that their solution is Wrong. It fails on the following case: A = {0, 0, 0}, B = {1, 2, 1} Output should be 2, but their code is giving 3.

Edit: there can be two variation of this problem:

1st — When K is a positive integer

2nd — When K can be any integer

There might be different solution for both. So answer by assuming each case.

Full text and comments »

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

By gjaiswal108, history, 4 years ago, In English

In ICPC India online round the 3rd problem was related to manipulation on line segments.I want to solve many more problem like this. Where can I find all the problems related to segments. If someone has list of these type of problems then please post the links in comment.

Edit: I already tried to search for this tag, but there is no such tag in problemset. That's why I posted here.

Full text and comments »

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

By gjaiswal108, history, 4 years ago, In English

Please add a feature to find out the list of all the div3 contests or div2/div1/educational contest links at a single page. It may further be improved by sort by date range(for example ,if I missed contests for few months then I am interested to find how many contests happened so that I can do that again virtually.)

Full text and comments »

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

By gjaiswal108, history, 5 years ago, In English

The thing we can do with priority queue, can also be done with multiset. Then what is the quality that's unique in priority queue? Can anyone give any example where multiset fails and only priority queue works?

Full text and comments »

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

By gjaiswal108, history, 5 years ago, In English

Getting TLE on using unordered_map, while AC on using map for problem E. Can anyone explain why??(I think unordered_map should be faster than map because its time complexity is O(1) for all operation.)

Link for Problem 1077E

Link for TLE Solution

Link for AC Solution

Full text and comments »

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