Please read the new rule regarding the restriction on the use of AI tools. ×

sandeep_iitpkd's blog

By sandeep_iitpkd, history, 14 months ago, In English

Hi there, I don't understand why I am getting TLE here submission Can someone help me?

  • Vote: I like it
  • +4
  • Vote: I do not like it

| Write comment?
»
14 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Maybe because you have large vector (arr) inside of function (solve). Try to make this vector global.

»
14 months ago, # |
  Vote: I like it +3 Vote: I do not like it

I think the problem is in your cond function, try this.

bool cond(const pair<int, int>& p1, const pair<int, int>& p2){
    return p1.first > p2.first || (p1.first == p2.first && p1.second < p2.second);
}