codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

357A.md (2178B)


      1 Source: https://codeforces.com/problemset/problem/357/A
      2 
      3 A. Group of Students
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 Help the university pick the passing rate in a way that meets these requirements.
     24 
     25 Input
     26 
     27 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.
     28 
     29 Output
     30 
     31 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.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 5  
     39 3 4 3 2 1  
     40 6 8
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 3
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 5  
     53 0 3 3 4 2  
     54 3 10
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 4
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 2  
     67 2 5  
     68 3 6
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 0
     75 ```
     76 
     77 Note
     78 
     79 In the first sample the beginner group has 7 students, the intermediate group has 6 of them.
     80 
     81 In the second sample another correct answer is 3.