Блог пользователя Whitewiz

Автор Whitewiz, история, 4 месяца назад, По-английски

problem

My solution : (https://mirror.codeforces.com/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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор Whitewiz, история, 4 месяца назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

Автор Whitewiz, история, 5 месяцев назад, По-английски

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://mirror.codeforces.com/contest/1985/submission/265437274) ,(https://mirror.codeforces.com/contest/1985/submission/265439252)

Hacked — (https://mirror.codeforces.com/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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор Whitewiz, история, 7 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится