标签:需求 for pac col style 而且 while ble 包括
2 2
3
3
9
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define LL long long #define maxn 2017 #define inf 100000000 using namespace std; int l1,l2,n,m,vc,vr,row[maxn],col[maxn]; LL ans; int main(){ scanf("%d%d",&n,&m); for(int i=1;i<n;i++)scanf("%d",&row[i]); for(int i=1;i<m;i++)scanf("%d",&col[i]); sort(row+1,row+n);sort(col+1,col+m); l1=n-1;l2=m-1;vc=1;vr=1; while(1){ if(!l1&&!l2)break; if(l1==0)row[l1]=-inf; if(l2==0)col[l2]=-inf; if(row[l1]>=col[l2]){ vr++; ans+=vc*row[l1--]; }else vc++,ans+=vr*col[l2--]; } printf("%lld\n",ans); return 0; }
标签:需求 for pac col style 而且 while ble 包括
原文地址:http://www.cnblogs.com/zzyh/p/7642475.html