-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcd3.cpp
More file actions
40 lines (39 loc) · 924 Bytes
/
Copy pathcd3.cpp
File metadata and controls
40 lines (39 loc) · 924 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
long long n,k,q;
cin>>n>>k>>q;
vector<long long> a(k);
for(int i=0;i<k;i++)
cin>>a[i];
vector<long long> b(k);
for(int i=0;i<k;i++)
cin>>b[i];
for(int i=0;i<q;i++) // q
{
long long d;
cin>>d;
auto it = lower_bound(a.begin(),a.end(),d)-a.begin(); // logk
it--;
if(it==-1)
{
long long dist = a[0];
long long time = b[0];
cout<<(d*time)/dist<<" ";
}
else
{
long long dist = a[it+1]-a[it];
long long time = b[it+1]-b[it];
cout<<((d-a[it])*time)/dist+b[it]<<" ";
}
}
cout<<endl;
}
return 0;
}