Skip to content

Instantly share code, notes, and snippets.

@TristenHarr
Created February 12, 2017 22:28
Show Gist options
  • Select an option

  • Save TristenHarr/7c1b8a5d4e4f986e4ebf4da68be0ffa3 to your computer and use it in GitHub Desktop.

Select an option

Save TristenHarr/7c1b8a5d4e4f986e4ebf4da68be0ffa3 to your computer and use it in GitHub Desktop.
import timeit
x = timeit.timeit()
import sys
first = sys.stdin.read().split('\n')
n,q,box,values = list(map(lambda x: int(x), first[0].split(' ')))[0],list(map(lambda x: int(x), first[0].split(' ')))[1], list(map(lambda x: int(x), first[1].split(' '))), first[2:]
finals = []
for item in values:
try:
n,l,r,c = list(map(lambda x: int(x), item.split(' ')))
if n == 1:
box[l:r + 1] = list(map(lambda x: x + c , box[l:r + 1]))
elif n == 2:
box[l:r + 1] = list(map(lambda x: x // c , box[l:r + 1]))
except ValueError:
n, l, r = list(map(lambda x: int(x), item.split(' ')))
if n == 3:
finals.append(str(min(box[l:r+1])))
elif n == 4:
finals.append(str(sum(box[l:r+1])))
sys.stdout.write('\n'.join(finals))
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment