Created
March 13, 2026 20:07
-
-
Save maehrm/2a3f1ee5c1d04f8a742cedcb26285fe1 to your computer and use it in GitHub Desktop.
D - Left Right Operation https://atcoder.jp/contests/abc263/tasks/abc263_d
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, L, R = map(int, input().split()) | |
| A = list(map(int, input().split())) | |
| revA = A[::-1] # 逆順にしておく | |
| # dpl[i]: 左からi番目まで見たときの最小値 | |
| # dpr[i]: 右からi番目まで見たときの最小値 | |
| dpl = [0] * (N + 1) | |
| dpr = [0] * (N + 1) | |
| for i in range(N): | |
| dpl[i + 1] = min(dpl[i] + A[i], L * (i + 1)) | |
| dpr[i + 1] = min(dpr[i] + revA[i], R * (i + 1)) | |
| dpr = dpr[::-1] | |
| print(min(x + y for x, y in zip(dpl, dpr))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment