C City now to transfer a number of criminals to D City, C city has n criminals, in accordance with the Order of imprisonment, and each criminal has a crime value, the greater the value of the greater the crime. Now, to facilitate management, the mayor decided to shift the number of C-inmates in jail for a continuous period of time, and demanded that the crime of transferring prisoners not exceed T, asking how many options were available?
Input Description:
The first row of data three integers: N,t,c (1≤n≤2e5,0≤t≤1e9,1≤c≤n), the second line gives the crime value of each prisoner at the time of imprisonment AI (0≤AI≤1E9)
Output Description:
One line to output the answer.
Input Example:
3 100 2
1 2 3
Output Example:
2
//Java versionImportJava.util.Scanner; Public classMain { Public Static voidMain (string[] args) {Scanner input=NewScanner (system.in); while(Input.hasnext ()) {intn=Input.nextint (); Longt=Input.nextint (); intC=Input.nextint (); Longa[]=New Long[n]; intCount=0; LongAmount=0; for(inti=0; i<n; i++) {A[i]=Input.nextlong (); } for(inti=0; i<c; i++) {Amount+=A[i]; } if(amount<=t) + +count; for(intI=1; i<=n-c; i++) {Amount=amount-a[i-1]+a[i+c-1]; if(amount<=t) + +count; } System.out.println (count); } input.close (); }}
Baidu Online Pen test-criminals transfer