fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n, k;
  7. cin >> n >> k;
  8.  
  9. vector<int> arr(n);
  10. for(int i = 0; i < n; i++) {
  11. cin >> arr[i];
  12. }
  13.  
  14. int count = 0;
  15.  
  16. for(int i = 0; i < n; i++) {
  17. int sum = 0;
  18. for(int j = i; j < n; j++) {
  19. sum += arr[j];
  20. if(sum >= k) {
  21. count++;
  22. }
  23. }
  24. }
  25.  
  26. cout << endl;
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5264KB
stdin
15 10 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
stdout