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

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

Find the number of ways to partition array into segments such that sum of each segments is greater than 0,

Note- Concatenating the segments should result into full array.

Constraints: 1<=N<=10^5 1<=a[I]<=10^9 Example:

Input1: N=3, a[]={-1,-3,7}

Output: 1. (Complete array as one Segment)

Thanks

PS. This is not part of any running Contest.

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

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

Автор Kr_Shubham, 3 года назад, По-английски

This code is taking around 1300 ms. (size of set shouldn't exceed more than 1 at any time, Since I am inserting same element every time)

Spoiler

But , After commenting the s.erase(), it just took 15 ms.

Spoiler

Can anyone please explain the reason behind this? Thanks in advance :)

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

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