67 lines
1.1 KiB
C++
67 lines
1.1 KiB
C++
#include <bits/stdc++.h>
|
|
|
|
// https://codeforces.com/blog/entry/96344
|
|
|
|
#pragma GCC optimize("O2,unroll-loops")
|
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
|
|
|
using namespace std;
|
|
|
|
template <typename T>
|
|
T MAX() {
|
|
return std::numeric_limits<T>::max();
|
|
}
|
|
|
|
template <typename T>
|
|
T MIN() {
|
|
return std::numeric_limits<T>::min();
|
|
}
|
|
|
|
#define ff first
|
|
#define ss second
|
|
#define eb emplace_back
|
|
#define ll long long
|
|
#define ld long double
|
|
#define vec vector
|
|
|
|
#define all(x) (x).begin(), (x).end()
|
|
#define rall(x) (r).rbegin(), (x).rend()
|
|
#define sz(x) static_cast<int>((x).size())
|
|
|
|
#ifdef LOCAL
|
|
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
|
#else
|
|
#define dbg(x)
|
|
#endif
|
|
|
|
static constexpr int MOD = 1e9 + 7;
|
|
|
|
void solve() {
|
|
int n, k;
|
|
cin >> n >> k;
|
|
vec<int> people(n);
|
|
for (auto &e : people) cin >> e;
|
|
int ans = 0, robin = 0;
|
|
for (auto amount : people) {
|
|
if (amount >= k)
|
|
robin += amount;
|
|
else if (robin > 0 && amount == 0) {
|
|
--robin;
|
|
++ans;
|
|
}
|
|
}
|
|
cout << ans << '\n';
|
|
}
|
|
|
|
int main() {
|
|
cin.tie(nullptr)->sync_with_stdio(false);
|
|
|
|
int t = 1;
|
|
cin >> t;
|
|
|
|
while (t--) {
|
|
solve();
|
|
}
|
|
|
|
return 0;
|
|
}
|