Skip to content

Instantly share code, notes, and snippets.

@SF-Zhou
Created March 26, 2017 08:51
Show Gist options
  • Save SF-Zhou/25bff304e91d582a837f6659937c7e5a to your computer and use it in GitHub Desktop.
Save SF-Zhou/25bff304e91d582a837f6659937c7e5a to your computer and use it in GitHub Desktop.
2017 Netease To Company
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <unordered_map>
using namespace std;
#define ff(i, n) for (int i = 0, END = (n); i < END; i ++)
#define fff(i, n, m) for (int i = (n), END = (m); i <= END; i ++)
#define dff(i, n, m) for (int i = (n), END = (m); i >= END; i --)
#define travel(e, first) for (int e = first, v = vv[first]; ~e; e = nxt[e], v = vv[e])
#define clr(a, b) memset(a, b, sizeof(a))
typedef long long ll;
int n;
const int N = 55;
int tx[N], ty[N];
int gx, gy;
int wt, tt;
void input() {
ff (i, n) { scanf("%d", tx + i); }
ff (i, n) { scanf("%d", ty + i); }
scanf("%d%d", &gx, &gy);
scanf("%d%d", &wt, &tt);
tx[n] = gx, ty[n] = gy, n ++;
}
int dis(int x1, int y1, int x2, int y2) {
return abs(x1 - x2) + abs(y1 - y2);
}
int main() {
while (scanf("%d", &n) == 1) {
input();
int ans = 2E9 + 10;
ff (i, n) {
int now = 0;
now += dis(0, 0, tx[i], ty[i]) * wt;
now += dis(gx, gy, tx[i], ty[i]) * tt;
ans = min(ans, now);
}
printf("%d\n", ans);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment