| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 33 | 23 | 21 | 72.414% |
You are given two integer arrays $A$ and $B$, each of length $N$.
You want to select one contiguous subarray of length $K$ from each array to maximize the sum of the elements in the two chosen subarrays. However, the starting position of the subarray chosen from array $A$ must be strictly earlier than the starting position of the subarray from array $B$.
Formally, for integers $a$, $b$ satisfying $1 \le a < b \le N-K+1$ define
\[S(a, b) = \sum_{i = a}^{a + K - 1} A_i + \sum_{i = b}^{b + K - 1} B_i.\]
Your task is to find the maximum possible value of $S(a, b)$
The first line contains two integers $N$ and $K$, the length of the arrays and the length of each subarray. ($2 \le N \le 100\,000, 1 \le K \le N-1$)
The second line contains $N$ integers $A_1, A_2, \ldots, A_N$. ($-1\,000 \le A_i \le 1\,000$)
The third line contains $N$ integers $B_1, B_2, \ldots, B_N$. ($-1\,000 \le B_i \le 1\,000$)
Print a single integer: the maximum possible value of $S(a, b)$ under the given conditions.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 40 | $2 \le N \le 100$ |
| 2 | 40 | $2 \le N \le 3\,000$ |
| 3 | 20 | $2 \le N \le 100\,000$ |
4 2 3 4 5 6 10 1 1 1
11
In the example above, choosing a and b as illustrated yields the optimal result, and the value of $S(a, b)$ is 4+5+1+1 = 11. This example satisfies the conditions of all subtasks.
2 1 1 2 3 4
5
This example satisfies the conditions of all subtasks.
6 3 1 1 10 10 10 1 -50 -50 -1 -1 -1 -50
18
This example satisfies the conditions of all subtasks.
University > 서강대학교 > CSE4152 문제해결프로그래밍실습 > 2025-2학기 기말고사 코딩 테스트 3번