| 记录编号 | 352010 | 评测结果 | AAAAAAAAAA | 
    
        | 题目名称 | 2550.冰桥,升起来了! | 最终得分 | 100 | 
    
        | 用户昵称 |  jinqiu | 是否通过 | 通过 | 
    
        | 代码语言 | C++ | 运行时间 | 0.435 s | 
    
        | 提交时间 | 2016-11-16 20:30:17 | 内存使用 | 1.69 MiB | 
    
    
    
    		显示代码纯文本
		
		#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 4e4 + 10, maxm = 1e5 + 10;
int A, B, m, ans;
int a[maxn], b[maxn];
int fa[maxn], fb[maxn];
pair<int, int>edge[maxm];
int main() {
	freopen("meibridge.in", "r", stdin);
	freopen("meibridge.out", "w", stdout);
	int i;
	cin >> A >> B >> m;
	for(i = 1; i <= A; i++) scanf("%d", a + i);
	for(i = 1; i <= B; i++) scanf("%d", b + i);
	for(i = 1; i <= m; i++) scanf("%d%d", &edge[i].first, &edge[i].second);
	sort(edge + 1, edge + m + 1);
	for(i = 1; i <= A; i++) {
		fa[i] = a[i];
		ans = max(ans, fa[i]);
	}
	for(i = 1; i <= B; i++) {
		fb[i] = b[i];
		ans = max(ans, fb[i]);
	}
	for(i = 1; i <= m; i++) {
		int u = edge[i].first, v = edge[i].second;
		int ta = fa[u], tb = fb[v];
		fa[u] = max(fa[u], tb + a[u]);
		fb[v] = max(fb[v], ta + b[v]);
		ans = max(ans, max(fa[u], fb[v]));
	}
	cout << ans << "\n";
	return 0;
}