Created
March 15, 2026 00:32
-
-
Save maehrm/77f7b5fd16c214cad847385096d3990e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| N, D, K = map(int, input().split()) | |
| LR = [list(map(int, input().split())) for _ in range(D)] | |
| ST = [list(map(int, input().split())) for _ in range(K)] | |
| ans = [-1] * K | |
| for i in range(D): # i日目 | |
| l, r = LR[i] | |
| for j in range(K): # j番目の民族の移動 | |
| if ans[j] != -1: | |
| continue | |
| cur, goal = ST[j] | |
| if cur < goal and cur >= l and cur <= r: # 現在地がゴールの左側のとき | |
| cur = min(r, goal) | |
| if goal < cur and cur <= r and cur >= l: # 現在地がゴールの右側のとき | |
| cur = max(l, goal) | |
| ST[j][0] = cur | |
| if cur == goal: | |
| ans[j] = str(i + 1) | |
| print("\n".join(ans)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment