Please, Can someone check my submission why my submission giving TLE ?

Before contest

Codeforces Round sponsored by NEAR (Div. 1 + Div. 2)

3 days

Register now »

Codeforces Round sponsored by NEAR (Div. 1 + Div. 2)

3 days

Register now »

*has extra registration

# | User | Rating |
---|---|---|

1 | tourist | 3803 |

2 | jiangly | 3707 |

3 | Benq | 3627 |

4 | ecnerwala | 3584 |

5 | orzdevinwang | 3573 |

6 | Geothermal | 3569 |

6 | cnnfls_csy | 3569 |

8 | Radewoosh | 3542 |

9 | jqdai0815 | 3532 |

10 | gyh20 | 3447 |

# | User | Contrib. |
---|---|---|

1 | awoo | 162 |

2 | maomao90 | 160 |

3 | adamant | 157 |

4 | maroonrk | 154 |

5 | -is-this-fft- | 150 |

6 | Petr | 148 |

6 | SecondThread | 148 |

8 | atcoder_official | 147 |

9 | TheScrasse | 145 |

9 | nor | 145 |

Please, Can someone check my submission why my submission giving TLE ?

Most of the time I got the wrong anwers on hidden test cases like Wrong Answer on 91 test case (Test 2) or 2000 test case (Test 7) etc.

Sometimes after trying all possible corner test cases and some random test cases I am not able to find which type of test case give the wrong answer.

I will highly grateful to you if you can give me some ideas which are really helpful to find those hidden test cases.

Thank You.

I am trying DP questions from a while but still i stuck in some questions Please clear my small doubt, Let's say in any DP question i need to make a dp matrix by considering a value in the row and another one in the column. My confusion is which one i should put in row and which one i should put in the column or i can put any of them at any place because in knapsack problem i can use any parameter in both row or column Here Using number of itmes in the row and here Using total weight in the row.

Thank you.

Can anyone help me, which is more efficient while using in the for loop?

`for(u = 2; u <= sqrt(n); u++)`

or

`for(u = 2; u*u <= n; u++)`

Here are my both submission

Using first method — 119098252

Using second method — 119098208

While using the first method i got TLE but the same code using with the second method got Accepted..

I am assuming that method one is calculating `sqrt(n)`

again and again and other one is calculating `u*u`

again and again then why one is got accepted other one is not.

Please tell me the reason behind this?

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/15/2024 23:44:42 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|