补题cf944 E题 #wa4
作者:
多米尼克領主的致意
,
2024-05-11 17:02:24
,
所有人可见
,
阅读 4
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], b[N], s[N];
double f[N];
int t;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while(t--){
int n, k, q;
cin >> n >> k >> q;
for(int i = 1;i <= k;i++)cin >> a[i];
for(int i = 1;i <= k;i++)cin >> b[i];
for(int i = 1;i <= k;i++){
f[i] = (double)(b[i] - s[i - 1]) / (a[i] - a[i - 1]);
s[i] = s[i - 1] + f[i] * (a[i] - a[i - 1]);
// cout << f[i] << " ";
// cout << s[i] << " ";
}
cout << endl;
while(q--)
{
int x;
cin >> x;
int l = 0, r = k;
while(l < r)
{
int mid = (l + r + 1) >> 1;
if(a[mid] < x)l = mid;
else r = mid - 1;
}
// cout << s[l] << " ";
double ans = s[l] + f[l + 1] * (x - a[l]);
int res = ans;
// cout << ans << " ";
cout << res << " ";
}
cout << endl;
}
return 0;
}