Submission
Status:
PPPPPPPPPP
Score: 100
User: Pera
Problemset: เข้าแถว
Language: python
Time: 0.130 second
Submitted On: 2025-04-14 19:05:15
def main():
n, l = list(map(int, input().split()))
height: list = list(map(int, input().split()))
# this is one indexed
need_chairs: list = sorted(list(map(int, input().split())))
res: list = []
for idx in need_chairs:
# first person
if idx == 1:
res.append(0)
else:
maxb4needchair: int = max(height[:idx - 1])
if maxb4needchair >= height[idx - 1]:
res.append((maxb4needchair + 1) - height[idx - 1])
# height[idx - 1] = maxb4needchair + 1
else:
res.append(0)
for r in res:
print(r)
main()