#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n, m;
int main()
{
int T;
scanf("%d", &T);
while (T -- )
{
cin >> n >> m;
int temp = m, cnt = 1;
for (int i = 0; i < n; i ++ )
{
int x;
cin >> x;
if (temp - x < 0)
{
cnt ++ ;
temp = m;
}
temp -= x;
}
cout << cnt << endl;
}
return 0;
}
二叉树中第二小结点
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
typedef long long LL;
long long t = 0;
int rootval = 0;
void dfs(TreeNode* root)
{
if (root == nullptr)
return ;
if (root->left && root->left->val != rootval)
t = min(t, (LL)root->left->val);
if (root->right && root->right->val != rootval)
t = min(t, (LL)root->right->val);
dfs(root->left);
dfs(root->right);
}
int findSecondMinimumValue(TreeNode* root) {
rootval = root->val;
t = 2147483648;
dfs(root);
if (t == 2147483648)
return -1;
return t;
}
};