fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. const int INF= 1e9+7;
  5. ll n,k,res=1,a[1000005];
  6.  
  7. int main(){
  8. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  9. cin >> n >> k;
  10. for(int i=1;i<=n;i++) cin>>a[i],a[i]-=k;
  11. for(int i=2;i<=n;i++) a[i]+=a[i-1];
  12. for(int i=1;i<=n;i++) {
  13. while(a[i]-a[i-res]>=0) res++;
  14. }
  15. cout << res-1;
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0.01s 5288KB
stdin
7 0
-2 2 -1 0 -2 1 -2 
stdout
3