301885: CF357A. Group of Students

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Group of Students

题意翻译

有一些学生考了试,他们在考试中获得了$1$~$m$的分数,获得 i 分的有 $C_i$人。\ 你需要求出一个分数线,满足低于分数线的人数和高于分数线(含)的人数均在$[x,y]$范围之内 ### 输入格式 ------------ 第一行一个整数,$m$\ 第二行$m$个整数,为$C_1$~$C_m$ 第三行两个整数$x,y$ ### 输出格式 ------------ 输出分数线,特别的,若没有满足要求的分数线,输出0

题目描述

At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to the results, each student got some score from 1 to $ m $ points. We know that $ c_{1} $ schoolchildren got 1 point, $ c_{2} $ children got 2 points, ..., $ c_{m} $ children got $ m $ points. Now you need to set the passing rate $ k $ (integer from 1 to $ m $ ): all schoolchildren who got less than $ k $ points go to the beginner group and those who get at strictly least $ k $ points go to the intermediate group. We know that if the size of a group is more than $ y $ , then the university won't find a room for them. We also know that if a group has less than $ x $ schoolchildren, then it is too small and there's no point in having classes with it. So, you need to split all schoolchildren into two groups so that the size of each group was from $ x $ to $ y $ , inclusive. Help the university pick the passing rate in a way that meets these requirements.

输入输出格式

输入格式


The first line contains integer $ m $ ( $ 2<=m<=100 $ ). The second line contains $ m $ integers $ c_{1} $ , $ c_{2} $ , ..., $ c_{m} $ , separated by single spaces ( $ 0<=c_{i}<=100 $ ). The third line contains two space-separated integers $ x $ and $ y $ ( $ 1<=x<=y<=10000 $ ). At least one $ c_{i} $ is greater than 0.

输出格式


If it is impossible to pick a passing rate in a way that makes the size of each resulting groups at least $ x $ and at most $ y $ , print 0. Otherwise, print an integer from 1 to $ m $ — the passing rate you'd like to suggest. If there are multiple possible answers, print any of them.

输入输出样例

输入样例 #1

5
3 4 3 2 1
6 8

输出样例 #1

3

输入样例 #2

5
0 3 3 4 2
3 10

输出样例 #2

4

输入样例 #3

2
2 5
3 6

输出样例 #3

0

说明

In the first sample the beginner group has 7 students, the intermediate group has 6 of them. In the second sample another correct answer is 3.

Input

题意翻译

有一些学生考了试,他们在考试中获得了$1$~$m$的分数,获得 i 分的有 $C_i$人。\ 你需要求出一个分数线,满足低于分数线的人数和高于分数线(含)的人数均在$[x,y]$范围之内 ### 输入格式 ------------ 第一行一个整数,$m$\ 第二行$m$个整数,为$C_1$~$C_m$ 第三行两个整数$x,y$ ### 输出格式 ------------ 输出分数线,特别的,若没有满足要求的分数线,输出0

加入题单

上一题 下一题 算法标签: