fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N = 1e3;
  5.  
  6. long long n, S, a[N + 10], ans;
  7.  
  8. void nhap(){
  9. cin >> n >> S;
  10. for(int i = 1; i <= n; i++) cin >> a[i];
  11. }
  12. void solve(){
  13. for(int R = 1; R <= n; R++){
  14. long long csum = 0;
  15. for(int L = R; L >= 1; L--){
  16. csum += a[L];
  17. if(abs(csum) > S) ans++;
  18. }
  19. }
  20. cout << ans;
  21. }
  22. int main() {
  23. ios_base::sync_with_stdio(0);
  24. cin.tie(0); cout.tie(0);
  25. nhap();
  26. solve();
  27. return 0;
  28. }
Success #stdin #stdout 0s 5292KB
stdin
10 7
-4 9 2 -11 -3 8 -6 5 -3 1
stdout
12