Codeforces Round 944 (Div. 4) E. Find the Car

Codeforces Round 944 (Div. 4)

E. Find the Car

计算时必须先乘后除

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// By SnowDream
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
int n,k,q,d;
ll a[N],b[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--)
{
cin >> n >> k >> q;
for(int i=1;i<=k;++i)
{
cin >> a[i];
}
for(int i=1;i<=k;++i)
{
cin >> b[i];
}
while(q--)
{
cin >> d;
if(d==0)
{
cout << 0 << " ";
continue;
}
ll i = lower_bound(a,a+k+1,d)-a;
ll b_left=b[i-1],b_right=b[i];
cout << b_left + (b_right-b_left) * (d-a[i-1]) / (a[i]-a[i-1]) << " ";
}
cout << "\n";
}
return 0;
}

Codeforces Round 944 (Div. 4) E. Find the Car
http://snowdreamxue.github.io/2024/10/21/Codeforces Round 944 (Div. 4)/E. Find the Car/
Author
SnowDream
Posted on
October 21, 2024
Licensed under