Last active
February 15, 2026 01:25
-
-
Save maehrm/5372890a0e0e8ccbebb498da43690719 to your computer and use it in GitHub Desktop.
C - Tsundoku https://atcoder.jp/contests/abc172/tasks/abc172_c
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, M, K = map(int, input().split()) | |
| A = list(map(int, input().split())) | |
| B = list(map(int, input().split())) | |
| sumA = [0] | |
| for i in range(N): | |
| sumA.append(sumA[-1] + A[i]) | |
| sumB = [0] | |
| for i in range(M): | |
| sumB.append(sumB[-1] + B[i]) | |
| ans = 0 | |
| for i in range(len(sumA)): | |
| # Aをi冊選んだとき、Bが何冊読めるか? | |
| rest = K - sumA[i] | |
| if rest < 0: | |
| continue | |
| ok, ng = 0, len(sumB) | |
| while ng - ok > 1: | |
| mid = (ok + ng) // 2 | |
| if sumB[mid] <= rest: | |
| ok = mid | |
| else: | |
| ng = mid | |
| ans = max(i + ok, ans) | |
| print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment