CF357A.Group of Students
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
新学年开始时,贝尔兰国立大学在本市开设了两个面向中小学生的编程学习小组:初级组和中级组。为将学生分入合适的小组,学校对所有学生进行了测试。根据测试结果,每名学生获得了 1 到 m 分之间的某个整数分数。已知有 c1 名学生得了 1 分,c2 名学生得了 2 分,……,cm 名学生得了 m 分。现在你需要确定一个及格分数线 k(k 为 1 到 m 之间的整数):所有得分严格小于 k 的学生进入初级组,而得分大于等于 k 的学生进入中级组。我们还知道,若某组人数超过 y,则学校无法为其安排教室;而若某组人数少于 x,则该组规模过小,不值得单独开课。因此,你需要将所有学生恰好划分为两个组,使得每个组的人数均在 x 到 y(含端点)之间。
请帮助学校选择一个满足上述所有条件的及格分数线 k。
输入格式
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.
第一行包含一个整数 m(2 ≤ m ≤ 100)。
第二行包含 m 个整数 c1,c2,…,cm,以单个空格分隔(0 ≤ ci ≤ 100)。
第三行包含两个以空格分隔的整数 x 和 y(1 ≤ x ≤ y ≤ 10000)。
至少有一个 ci 大于 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.
如果无法选择一个及格率,使得每个分组的大小至少为 x 且至多为 y,则输出 0。否则,输出一个介于 1 到 m(含)之间的整数——即你建议的及格率。若存在多个可能的答案,输出其中任意一个即可。
输入输出样例
输入#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.
在第一个样例中,初级组有 7 名学生,中级组有 6 名学生。
在第二个样例中,另一个正确答案是 3。
输入解题思路,AI测评打分。不知道怎么写?