diff --git a/service_lane/service_lane.py b/service_lane/service_lane.py new file mode 100644 index 0000000..3e6dfb9 --- /dev/null +++ b/service_lane/service_lane.py @@ -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() + \ No newline at end of file diff --git a/service_lane/test1.in b/service_lane/test1.in new file mode 100644 index 0000000..666e82c --- /dev/null +++ b/service_lane/test1.in @@ -0,0 +1,7 @@ +8 5 +2 3 1 2 3 2 3 3 +0 3 +4 6 +6 7 +3 5 +0 7 \ No newline at end of file