You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
735 B
C++
35 lines
735 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
typedef long long ll;
|
|
const int N = 5050;
|
|
int a[N], b[N];
|
|
ll f(int i, int x)
|
|
{
|
|
return 1ll * (x - a[i]) * (x - a[i]) + b[i];
|
|
}
|
|
ll g(int x, int n)
|
|
{
|
|
ll mx;
|
|
memset(&mx, 0x3f, sizeof(mx));
|
|
for (int i = 1; i <= n; i++)
|
|
mx = min(mx, f(i, x));
|
|
return mx;
|
|
}
|
|
int main()
|
|
{
|
|
int n, q;
|
|
scanf("%d", &n);
|
|
for (int i = 1; i <= n; i++) scanf("%d", a + i);
|
|
for (int i = 1; i <= n; i++) scanf("%d", b + i);
|
|
scanf("%d", &q);
|
|
while (q--)
|
|
{
|
|
int x;
|
|
scanf("%d", &x);
|
|
printf("%lld ", g(x, n));
|
|
}
|
|
return 0;
|
|
}
|