Logo
(追記) (追記ここまで)

34746번 - Squid Game: Two Bridges 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB22191789.474%

문제

Sogang agent is participating in “Squid Game: Two Bridges”. There are two parallel bridges, A and B, each consisting of $N$ steps. Each step has a score. The player starts at the beginning and moves to the end for $N$ rounds. The player can only move forward along the bridge.

In each round, the player can either:

  1. jump to the next step on the same bridge without using any energy, or
  2. spend one unit of energy to jump to the next step on the other bridge.

When the player lands on a step, the step’s score is added to the total. Unlike the original Squid Game, there is no danger of dying in this version, and the agent will always finish the game.

Specifically, the agent starts on the starting point of the left bridge (A) with an initial score of 0ドル$ and initial energy $K,ドル shown in the figure below.

Given the score sequences $A$ (for the left bridge) and $B$ (for the right bridge), and the initial energy $K,ドル determine the maximum score the Sogang agent can achieve. The agent does not have to use all of the energy—it is also possible to use none at all.

입력

The first line contains two integers $N$ and $K,ドル the number of turns and the agent’s initial energy. $(1 \leq N \leq 100,000,円 0 \leq K \leq 4)$

The second lines contains $N$ integers, representing the left bridge's score sequence $A$. $(-1,000円 \leq A_i \leq 1,000円)$

The third line contains $N$ integers, representing the right birdge's sequence $B$. $(-1,000円 \leq B_i \leq 1,000円)$

출력

Print a single integer: the maximum score the Sogang agent can achieve.

제한

서브태스크

번호배점제한
140

1ドル \leq N \leq 1,000,円 K = 2$

In this subtask, all $A_i$ are equal to 0.

220

1ドル \leq N \leq 100,000,円 K = 2$

In this subtask, all $A_i$ are equal to 0.

320

1ドル \leq N \leq 100,000,円 0 \leq K \leq 2$

420

1ドル \leq N \leq 100,000,円 0 \leq K \leq 4$

예제 입력 1

6 2
0 0 0 0 0 0
3 -9 5 -2 8 -5

예제 출력 1

11

This example satisfies the conditions of Subtask 1, 2, 3 and 4.

예제 입력 2

6 2
0 0 0 0 0 0
-1 -2 -1 -2 -1 -2

예제 출력 2

0

This example satisfies the conditions of Subtask 1, 2, 3 and 4.

예제 입력 3

6 2
3 3 3 2 1 7
1 2 1 7 7 2

예제 출력 3

30

This example satisfies the conditions of Subtask 3 and 4.

예제 입력 4

6 4
1 9 0 6 6 6
9 1 9 1 7 3

예제 출력 4

45

This example satisfies the conditions of Subtask 4.

예제 입력 5

1 0
-5
5

예제 출력 5

-5

This example satisfies the conditions of Subtask 3 and 4.

노트

출처

University > 서강대학교 > CSE4152 문제해결프로그래밍실습 > 2025-2학기 중간고사 코딩 테스트 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /