stdfloat's blog

By stdfloat, 15 months ago, In English

I was trying to solve IZHO14_bank on oj.uz. In problem $$$n, m <= 20$$$ and Time Limit is 1s.

Time complexity of my solution is $$$O(2^m \cdot m \cdot n)$$$. It's $$$TLE$$$ because $$$2^{20} \cdot 20 \cdot 20 = 419 430 400 > 10^8$$$.

My both code have same time complexity but my $$$1^{st}$$$ code is $$$TLE$$$, $$$2^{nd}$$$ got $$$100$$$ score.

Can someone explain why my $$$2^{nd}$$$ code isn't $$$TLE$$$ $$$?$$$
$$$1^{st}$$$ submission https://oj.uz/submission/854216 gives $$$TLE$$$,
$$$2^{nd}$$$ submission https://oj.uz/submission/854864 got $$$100$$$ score.

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

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

2 operations on 2 closer elements make your code faster.

if you wanna know more