Whitewiz's blog

By Whitewiz, history, 4 months ago, In English

problem

My solution : (https://codeforces.me/contest/1651/submission/271500008)

MY idea :

Optimal strategy is to connect the extremes of the arrays to the other network. In doing so, we may connect the extremes of both arrays to each other.

Full text and comments »

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

By Whitewiz, history, 4 months ago, In English

Given an array of infinite length having all elements as 0.

2 numbers N,K. In the next N lines , 3 integers are given : l, r, and x.

you have to add x to all the elements in the range l to r (inclusive)

Your task is to find a subsequence that satisfies all the given conditions :

  • Subsequence size should be maximum

  • Lexicographically minimum

  • it must form an arithmetic progression i.e [z, z + k, z + 2k, z + 3k,..., z + (l — 1)k] here z is an arbitrary number and k is given in the input (see line 2) and l is the length of the subsequence.

META DATA :

1 <= x <= 1e9;

1 <= l <= r <= 1e9;

1 <= N <= 2e5;

1 <= k <= 1e9;

Note that N is not the length of the array

Any kind of help will be highly appreciated, thanks

Full text and comments »

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

By Whitewiz, history, 5 months ago, In English

I used accumulate for calculating the sum of elements of the array(which got hacked) however simply calculating the sum via iteration gives the correct result.

Am i missing something or is there any problem with using this "accumulate" thing.

Accepted — (https://codeforces.me/contest/1985/submission/265437274) ,(https://codeforces.me/contest/1985/submission/265439252)

Hacked — (https://codeforces.me/contest/1985/submission/265303752)

update — this idea of using all the attacks at once (at 1st second) requires to calculate the sum of the array ,but this sum can overflow (long long is insufficient). Better idea is to use the ceil division in the check function like this :

tot += ((have + cool[i] — 1)/cool[i]) * attack[i]; Hacker of the above solution helped me figure this out. Thanks a lot sammyuri sir.

Full text and comments »

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

By Whitewiz, history, 7 months ago, In English

link to the problem -- https://www.spoj.com/problems/STPAR/

my solution -- https://pastebin.com/JCvFy7zr

I am not able to detect my mistake in the code. Any kind of help will be highly appreciated. Thanks

Full text and comments »

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