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

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

This was my submission 256491105. Can somebody explain to me why this solution gives TLE?

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

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

You’re making an array of size $$$2e5+1$$$ for every test case and there are like $$$10^4$$$ tests. Instead you should’ve made the array of size $$$n+1$$$, and then proceeded with whatever you’re doing (this will get rid of the TLE)

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

the problem could be solved easily by counting number of cards having 2 ouccrences to get max score optimally . and your tle problem is solved by the guy before me

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

because u use (2e5+1) * (10^4) and this it too large, u can use map<int, int> instead