记录编号 |
380658 |
评测结果 |
AAAAA |
题目名称 |
[HAOI 2005]希望小学 |
最终得分 |
100 |
用户昵称 |
kZime |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.003 s |
提交时间 |
2017-03-09 20:53:22 |
内存使用 |
0.52 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int n, m, bv[3], gv[3], f[233][233], ans = 210000000, d;
struct v{
int g ;
int b ;
} v[33];
inline int read() {
int k = 0;
char c = getchar();
for(;!isdigit(c); c = getchar());
for(; isdigit(c); c = getchar())k = k * 10 + c - '0';
return k;
}
int main() {
#ifndef LOCAL
freopen("hopeschool.in", "r", stdin);
freopen("hopeschool.out", "w", stdout);
#endif
n = read();
bv[0] = read();
bv[1] = read();
bv[2] = read();
gv[0] = read();
gv[1] = read();
gv[2] = read();
for(int i = 1; i <= n; i++) {
v[i].b = read();
}
for(int i = 1; i <= n; i++) {
v[i].g = read();
}
memset(f, 0x2f, sizeof(f));
m = read();
for(int i = 1; i <= m; i++) {
int x = read();
int y = read();
int s1 = read();
int s2 = read();
int s3 = read();
f[x][y] = v[x].b * (s1 * bv[0] + s2 * bv[1] + s3 * bv[2]) + v[x].g * (s1 * gv[0] + s2 * gv[1] + s3 * gv[2]);
f[y][x] = v[y].b * (s1 * bv[0] + s3 * bv[1] + s2 * bv[2]) + v[y].g * (s1 * gv[0] + s3 * gv[1] + s2 * gv[2]);
}
for(int k = 1; k <= n; k++) {
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(f[i][k] + f[k][j] < f[i][j]) {
f[i][j] = f[i][k] + f[k][j];
}
}
}
}
for(int i = 1; i <= n; i++) {
int mx = 0;
for(int j = 1; j <= n; j++) {
if(i != j)
mx += f[j][i];
}
if(ans > mx){
ans = mx;
d = i;
}
}
printf("%d",d);
return 0;
}
/*
3 2 2 2 3 3 3
10 12 5
5 12 5
3
1 2 6 3 1
1 3 2 5 2
2 3 8 0 0
*/