Advertisement
Ankit_132

B

Jan 24th, 2024 (edited)
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int t;
  6.     cin>>t;
  7.    
  8.     while(t--)
  9.     {
  10.         int n, m;
  11.         cin>>n>>m;
  12.        
  13.         vector<int> a(n);
  14.         for(auto &e: a)     cin>>e;
  15.        
  16.         int tot = 0;
  17.         int ans = 0;
  18.        
  19.         for(auto e: a){
  20.             tot += e;
  21.            
  22.             if(tot >= m){
  23.                 ans++;
  24.                 tot = 0;
  25.             }
  26.         }
  27.        
  28.         cout<<ans<<"\n";
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement