Mayank and Golden Card
All submissions for this problem are available.Mayank has a challenge for Paawan. He has $N$ cards, numbered from $1$ to $N$, with each card having a number $A_i$ $(1 <= i <= n)$ written on it. He gives Paawan a Golden Card with a number $P$ on it. He asks Paawan to select some $K$ continuous cards from the deck of $N$ cards and sum the numbers that are present on the selected cards. Paawan's challenge is to minimise the number $K$, such that the sum of the selected cards is greater than the number $P$ on the Golden Card. Paawan needs your help to win, can you help him? ###Input: - The first line consists of T, the number of testcases. - The first line of each test case consists of two numbers $N$ and $P$, the number of cards in the deck and the number of the golden card. - The second line consists of $N$ numbers, $A_1$ to $A_n$. ###Output: - For each testcase, only one integer, the number $K$. If the sum of numbers on all $N$ cards doesn't satisfy the challenge, print $N+1$. ###Constraints - $1 \leq T \leq 10^4$ - $1 \leq N \leq 10^5$ - $1 \leq A_i \leq 10^9$ ###Subtasks - 30 points : $ T \leq 100$ - 70 points : original constraints ###Sample Input: 1 3 9 3 8 6 ###Sample Output: 2
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.