#include using namespace std; int a[1000000]; int main() { // freopen(".in","r",stdin); // freopen(".out","w",stdout); int t; cin>>t; for (int test = 0; test < t; test++) { int n, m; cin>>n>>m; for (int i = 0; i < n; i++) cin>>a[i]; int ost = 0; // residue of good pieces of bread long long ans = 0;// answer for (int i = 0; i < n; i++) { if (ost) { // if we have some residue pieces of bread in these package we use it ost--; // throw last bad piece of bread if (a[i] - ost > 0) { // if we need more pieces of bread than residue a[i] -= ost; // we use all residue int q = a[i] / m; // calculate how many package we need if (a[i] % m > 0) q++; //calculate new residue ost = m - (a[i] % m); if (a[i] % m == 0) ost = 0; ans += q; // increase answer } else { ost -= a[i]; // else if our residue more than we need then we reduce our residue a[i] = 0; } } else { // if we havent any residue int q = a[i] / m; // calculate how mane package we need if (a[i] % m > 0) q++; // calculate residue ost = m - (a[i] % m); if (a[i] % m == 0) ost = 0; ans += q; // increase answer } } cout<