SharvanCN1's blog

By SharvanCN1, history, 5 weeks ago, In English

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

  • Vote: I like it
  • -6
  • Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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)

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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