Browse Source

Solved Service Lane

main
Titouan Rigoudy 11 years ago
parent
commit
4264b0a899
2 changed files with 40 additions and 0 deletions
  1. +33
    -0
      service_lane/service_lane.py
  2. +7
    -0
      service_lane/test1.in

+ 33
- 0
service_lane/service_lane.py View File

@ -0,0 +1,33 @@
#!/usr/bin/python3
import sys
def nextints():
return [int(x) for x in sys.stdin.readline().split()]
def maxwidth_aux(width, i, j):
res = 3
for w in width[i:j+1]:
if w == 1:
return 1
res = min(res,w)
return res
def maxwidth(width, i, j, memo):
res = memo.get((i,j), None)
if res:
return res
res = maxwidth_aux(width, i, j)
memo[(i,j)] = res
return res
def main():
[N,T] = nextints()
width = nextints()
memo = dict()
for _ in range(T):
[i,j] = nextints()
print(maxwidth(width, i, j, memo))
main()

+ 7
- 0
service_lane/test1.in View File

@ -0,0 +1,7 @@
8 5
2 3 1 2 3 2 3 3
0 3
4 6
6 7
3 5
0 7

Loading…
Cancel
Save