codeforces-scrape

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

1279B.md (2328B)


      1 Source: https://codeforces.com/problemset/problem/1279/B
      2 
      3 B. Verse For Santa
      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 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 New Year is coming! Vasya has prepared a New Year's verse and wants to recite it in front of Santa Claus.
     22 
     23 Vasya's verse contains $n$ parts. It takes $a_i$ seconds to recite the $i$-th part. Vasya can't change the order of parts in the verse: firstly he recites the part which takes $a_1$ seconds, secondly — the part which takes $a_2$ seconds, and so on. After reciting the verse, Vasya will get the number of presents equal to the number of parts he fully recited.
     24 
     25 Vasya can skip at most one part of the verse while reciting it (if he skips more than one part, then Santa will definitely notice it).
     26 
     27 Santa will listen to Vasya's verse for no more than $s$ seconds. For example, if $s = 10$, $a = [100, 9, 1, 1]$, and Vasya skips the first part of verse, then he gets two presents.
     28 
     29 Note that it is possible to recite the whole verse (if there is enough time).
     30 
     31 Determine which part Vasya needs to skip to obtain the maximum possible number of gifts. If Vasya shouldn't skip anything, print 0. If there are multiple answers, print any of them.
     32 
     33 You have to process $t$ test cases.
     34 
     35 Input
     36 
     37 The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.
     38 
     39 The first line of each test case contains two integers $n$ and $s$ ($1 \le n \le 10^5, 1 \le s \le 10^9$) — the number of parts in the verse and the maximum number of seconds Santa will listen to Vasya, respectively.
     40 
     41 The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the time it takes to recite each part of the verse.
     42 
     43 It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.
     44 
     45 Output
     46 
     47 For each test case print one integer — the number of the part that Vasya needs to skip to obtain the maximum number of gifts. If Vasya shouldn't skip any parts, print 0.
     48 
     49 Example
     50 
     51 Input
     52 
     53 ```
     54 3
     55 7 11
     56 2 9 1 3 18 1 4
     57 4 35
     58 11 9 10 7
     59 1 8
     60 5
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 2
     67 1
     68 0
     69 ```
     70 
     71 Note
     72 
     73 In the first test case if Vasya skips the second part then he gets three gifts.
     74 
     75 In the second test case no matter what part of the verse Vasya skips.
     76 
     77 In the third test case Vasya can recite the whole verse.