-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathcp_templpate.py
60 lines (48 loc) · 1.35 KB
/
cp_templpate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import sys
import time
# using template by FenrisLycaon
def maxSequence(arr):
max, curr = 0, 0
for x in arr:
curr += x
if curr < 0:
curr = 0
if curr > max:
max = curr
return max
def getIn(x):
# custom input
# supposed to be faster
if x == "ints":
return list(map(int, sys.stdin.readline().strip().split()))
elif x == "int":
return int(sys.stdin.readline().strip().split()[0])
elif x == "float":
return float(map(float, sys.stdin.readline().strip().split()))
elif x == "list":
return list(map(sys.stdin.readline().strip().split()))
elif x == "str":
return str(sys.stdin.readline().strip())
elif x == "charlist":
return list(map(str, input().strip().split()))
else:
print("Input not recognised.")
return 0
def goOut(x):
# custom output
# supposed to be faster
if type(x) is list:
for _ in x:
goOut(_)
# sys.stdout.flush()
else:
sys.stdout.write(str(x) + "\n")
# sys.stdout.flush()
if __name__ == "__main__":
startingTime = time.time()
res = []
# code here
# output ahead
goOut(res)
# to check performance uncomment the next line
# goOut(time.time()-startingTime)