-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path拼多多.py
32 lines (28 loc) · 780 Bytes
/
拼多多.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
# encoding: utf-8
"""
@author: zxf_要努力
@file: 拼多多.py
@time: 2022/4/10 19:14
"""
import sys
def get_begin(M,N,left,right):
dp = [0] * (M +1)
for value in N:
dp[value] = 1
if left == right:
if dp[left] == 1:
return -1
else:
return left
else:
for i in range(left,right+1):
if dp[i] == 0:
return i
return -1
if __name__ == '__main__':
N,M = list(map(int,sys.stdin.readline().strip().split(" ")))
N_list = list(map(int,sys.stdin.readline().strip().split(" ")))
q = int(sys.stdin.readline().strip())
for _ in range(q):
left, rigth = list(map(int, sys.stdin.readline().strip().split(" ")))
print(get_begin(M, N_list, left, rigth))