#P15524. [ROIR 2015 Day 1] prizes 奖品选择
[ROIR 2015 Day 1] prizes 奖品选择
Problem Description
Alisa and Bob became the winners of a TV quiz show, and now they need to choose prizes. There are prizes, numbered from to .
The prize selection rules are as follows: The organizer gives a positive integer (). First, Alisa chooses consecutive prize indices. Then, Bob chooses consecutive prize indices, but he cannot choose any index that Alisa has already chosen. After that, the winners receive the prizes they selected.
Alisa knows Bob very well, and she knows how much each prize is worth to Bob (this is a positive integer). Alisa does not like Bob, so when choosing prizes, she wants to make the total value of the prizes Bob chooses as small as possible. Alisa does not care which prizes she gets.
Task: Write a program that, given the prize values and the value of , determines the minimum total value that Alisa can guarantee, so that the total value of the prizes Bob chooses will not exceed .
Input Format
The first line of the input file contains two integers: —— the total number of prizes, and —— the number of consecutive prizes each winner must choose (, ).
The second line contains integers: , where is the value of the -th prize to Bob ().
Output Format
The output file should contain one integer —— the minimum such that Alisa can make the total value of the prizes Bob chooses not exceed .
10 2
1 2 4 5 2 4 2 2 1 6
7
Hint
Explanation of the Example
In this example, Alisa can choose prizes and . Then Bob can choose prizes and , and the total value he gets is .
Scoring System and Subtasks
Subtask 1 (30 points)
, .
Subtask 2 (30 points)
, .
Subtask 3 (40 points)
, .
Translation source: GPT 5.2.
Translated by ChatGPT 5