Need help on 903D

Правка en1, от Siriuslight, 2017-12-13 01:01:22

I have implemented 903D using Mergesort Tree and maintaining a prefix sum vector for every vector of merge sort tree.

For every a[i], I am calculating the sum of all a[j], where a[j] > a[i]+1 or a[j] < a[i]-1, j < i. Using this sum I am subtracting this sum from answer and adding a[i], same number of times.

My submission. This error is because of integer overflow, but when I change all integers to long long. It gives me wrong answer.

Any help would be appreciated. :)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Siriuslight 2017-12-13 01:01:22 604 Initial revision (published)