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

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

I am getting MLE in test case 45 for C Question. I am not able to figure out the reason for it. Time Complexity and Space Complexity of my code are O(n^2) for each. Here's my submission. Can someone figure out my issue with my code ?

https://codeforces.net/contest/1678/submission/156387534

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

»
3 года назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Don't save the inversions in a vector, that just uses extra time and memory. Try instead to apply the increments to the dp array directly, and in the end just loop over the array again and find the inversions instead of using the vector (a)