F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Alice and Bob

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 920    Accepted Submission(s): 85


Problem Description
These days, Alice came up with a new game. In this game, there are some balls placed in a line which are numbered from L to R from left to right. It is known that N of the balls are white, while others are black. Alice will select aCount consecutive balls, after that, Bob will remove bCount balls from the balls that Alice has selected. Bob could remove those bCount balls one by one, for each ball he removes, he can choose whether to select the left most one or right most one.
The goal of Alice is to maximize the number of white balls after Bob's operation, and Bob's goal is to minimize this number.
So, what is the maximum number of white balls after Bob's operation?
 

Input
There are multiple test cases, for each case:
The first line is an integer N. (1 <= N <= 100,000)
The second line contains two integers L, R. (0 <= L <= R <= 263 - 1)
The third line contains two integers aCount, bCount.
The fourth line contains N integers p[0], p[1], ..., p[N - 1], denoting the positions of the white balls.
It is guaranteed that p[i - 1] < p[i] (1 <= i <= N - 1), L <= p[0], p[N - 1] <= R, 0 <= aCount <= R - L + 1, 0<=bCount <= aCount.
 

Output
For each test case, output one line representing the maximum number.
 

Sample Input
2 5 9 3 1 5 8 3 6 10 5 0 6 8 10
 

Sample Output
1 3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 08:18:02, Gzip enabled