Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Hi, there. I have made this submission while I was practicing: Submission link. The time complexity of this code is O(n). But I run the code I am TLE. I have also checked the editorial but I found no use. Beside the question there was an attention that time will be doubled. As I see in the test results the time consumed is 500ms, after getting doubled it becomes 1000ms which is TLE. Can someone help me to figure this out!!

Thank you in advance.

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

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

I've modified your code a little bit and it is accepted. submission

The main problem is that cin,cout,and endl are slow,so you need to use '\n' instead of endl, and add ios::sync_with_stdio(0);cin.tie(0); to the first line of main function to speed up cin and cout.