CF998B.Cutting

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are a lot of things which could be cut — trees, paper, "the rope". In this problem you are going to cut a sequence of integers.

There is a sequence of integers, which contains the equal number of even and odd numbers. Given a limited budget, you need to make maximum possible number of cuts such that each resulting segment will have the same number of odd and even integers.

Cuts separate a sequence to continuous (contiguous) segments. You may think about each cut as a break between two adjacent elements in a sequence. So after cutting each element belongs to exactly one segment. Say, [4,1,2,3,4,5,4,4,5,5][4, 1, 2, 3, 4, 5, 4, 4, 5, 5] \to two cuts \to [4,12,3,4,54,4,5,5][4, 1 | 2, 3, 4, 5 | 4, 4, 5, 5] . On each segment the number of even elements should be equal to the number of odd elements.

The cost of the cut between xx and yy numbers is xy|x - y| bitcoins. Find the maximum possible number of cuts that can be made while spending no more than BB bitcoins.

输入格式

First line of the input contains an integer nn ( 2n1002 \le n \le 100 ) and an integer BB ( 1B1001 \le B \le 100 ) — the number of elements in the sequence and the number of bitcoins you have.

Second line contains nn integers: a1a_1 , a2a_2 , ..., ana_n ( 1ai1001 \le a_i \le 100 ) — elements of the sequence, which contains the equal number of even and odd numbers

输出格式

Print the maximum possible number of cuts which can be made while spending no more than BB bitcoins.

输入输出样例

  • 输入#1

    6 4
    1 2 5 10 15 20
    

    输出#1

    1
    
  • 输入#2

    4 10
    1 3 2 4
    

    输出#2

    0
    
  • 输入#3

    6 100
    1 2 3 4 5 6
    

    输出#3

    2
    

说明/提示

In the first sample the optimal answer is to split sequence between 22 and 55 . Price of this cut is equal to 33 bitcoins.

In the second sample it is not possible to make even one cut even with unlimited number of bitcoins.

In the third sample the sequence should be cut between 22 and 33 , and between 44 and 55 . The total price of the cuts is 1+1=21 + 1 = 2 bitcoins.

首页