1 solutions
-
0
C++ :
#include<iostream> using namespace std; int main() { int n,m1,m2,i,j,ans1=0,ans2; int a[31],b[31]; int aa[1000],bb[1000],temp,flag; int aaa[1000],bbb[1000]; cin>>n>>m1>>m2; for(i=1;i<=m1;i++) cin>>a[i]; for(i=1;i<=m2;i++) cin>>b[i]; for(int i=1;i<=n;i++) { temp=0x7fffffff; for(int j=1;j<=m1;j++) if(aa[j]+a[j]<temp) { temp=aa[j]+a[j]; flag=j; } aaa[i]=aa[flag]=temp;//重要 } cout<<temp<<" "; for(int i=1;i<=n;i++) { temp=0x7fffffff; for(int j=1;j<=m2;j++) if(bb[j]+b[j]<temp) { temp=bb[j]+b[j]; flag=j; } bbb[i]=bb[flag]=temp;//重要 } int ans=0; for(i=1;i<=n;i++) if(aaa[i]+bbb[n-i+1]>ans) ans=aaa[i]+bbb[n-i+1]; cout<<ans; return 0; }
- 1
Information
- ID
- 19418
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By