记录编号 351405 评测结果 AAAAAAAAAA
题目名称 冰桥,升起来了! 最终得分 100
用户昵称 GravatarKulliu 是否通过 通过
代码语言 C++ 运行时间 0.148 s
提交时间 2016-11-16 15:25:30 内存使用 1.01 MiB
显示代码纯文本
#include<functional>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<ctime>
#include<list>
#include<map>
#include<set>
using namespace std;
#define F(i,l,r) for(int i=l;i<=r;i++)
#define D(i,r,l) for(int i=r;i>=l;i--)
typedef long long LL;
typedef double ld;
const int INF=0x7f7f7f7f;
const int M=100010,N=40010;
int a[N],b[N],n,m,k,fa[N],fb[N];
struct node{int x,y;}e[M];
inline bool com(const node &a,const node &b){
    if(a.x!=b.x)return a.x<b.x;
    return a.y<b.y;
}
int Main(){
    freopen("meibridge.in","r",stdin);
    freopen("meibridge.out","w",stdout);
    scanf("%d%d%d",&n,&m,&k);
    F(i,1,n)scanf("%d",&a[i]),fa[i]=a[i];
    F(i,1,m)scanf("%d",&b[i]),fb[i]=b[i];
    F(i,1,k)scanf("%d%d",&e[i].x,&e[i].y);
    sort(e+1,e+k+1,com);
    F(i,1,k){
        int tp1=fa[e[i].x],tp2=fb[e[i].y];
        if(fa[e[i].x]<tp2+a[e[i].x])fa[e[i].x]=tp2+a[e[i].x];
        if(fb[e[i].y]<tp1+b[e[i].y])fb[e[i].y]=tp1+b[e[i].y];
    }
    int maxm=0;
    F(i,1,n)if(fa[i]>maxm)maxm=fa[i];
    F(i,1,m)if(fb[i]>maxm)maxm=fb[i];
    printf("%d\n",maxm);
    return 0;
}
int start=Main();
int main(){;}