rt,如下是代码:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int t, n, m, L, V, cnt, now, res, d[N], v[N], a[N], p[N];
pair<int, int> q[N];
int main()
{
// freopen("detect5.in", "r", stdin);
// freopen("detect5.out", "w", stdout);
ios::sync_with_stdio(0), cin.tie(0);
cin >> t;
while (t--)
{
cin >> n >> m >> L >> V;
res = cnt = 0, now = 1;
for (int i = 1; i <= n; ++i) cin >> d[i] >> v[i] >> a[i];
for (int i = 1; i <= m; ++i) cin >> p[i];
for (int i = 1; i <= n; ++i)
{
if (lower_bound(p + 1, p + m + 1, d[i]) - p == m + 1) continue;
if (!a[i]) { if (v[i] > V) q[++cnt] = make_pair(L, d[i]); }
else if (a[i] > 0)
{
if (v[i] > V) q[++cnt] = make_pair(L, d[i]);
else
{
int l = d[i] + (V * V - v[i] * v[i] - 1) / (a[i] << 1) + 1;
if (lower_bound(p + 1, p + m + 1, l) - p != m + 1) q[++cnt] = make_pair(L, l);
}
}
else if (v[i] > V)
{
int l = d[i] + (V * V - v[i] * v[i] + 1) / (a[i] << 1);
if (p[lower_bound(p + 1, p + m + 1, d[i]) - p] <= l) q[++cnt] = make_pair(l, d[i]);
}
}
sort(q + 1, q + cnt + 1);
for (int i = 1; i <= m; ++i)
if (p[i + 1] > q[now].first || i == m)
{
while (now <= cnt && q[now].second <= p[i]) ++now;
if (now > cnt) { res += m - i; break; }
}
else ++res;
cout << cnt << ' ' << res << '\n';
}
return 0;
}