You are not logged in. Please login at www.codechef.com to post your questions!

×

TLE in python 3

can anybody suggest me how to overcome time limit in python 3. plzz share any tips . i have come with the best algorithm but still got a time limit for my code.i think my method of input is slow so plzz share a fastest method of input

asked 11 Nov '18, 17:27

itz_pankaj's gravatar image

2★itz_pankaj
11
accept rate: 0%


The fastest method of input is by using... "from sys import stdin" on the top of the code and Wherever you are using the command 'input()' replace it with 'stdin.readline()'.

link

answered 11 Nov '18, 19:54

harsha_man's gravatar image

4★harsha_man
193
accept rate: 0%

edited 11 Nov '18, 19:54

well thanks @harsha_man it works for my code

(12 Nov '18, 12:08) itz_pankaj2★

we can even print the output faster using the 'stdout.write(str(answer))'

(12 Nov '18, 14:35) harsha_man4★

yeah me too!

link

answered 11 Nov '18, 19:06

nebex's gravatar image

2★nebex
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×521
×267
×148
×70
×26
×23
×20
×1

question asked: 11 Nov '18, 17:27

question was seen: 248 times

last updated: 12 Nov '18, 14:35