CF1206A

CF1206A

题意:

给你 $ a , b $ 两个数组,要求从两个数组中各选一个数,使得它们的和不存在于任何一个数组。

解法:

一道极端签到的题。
因为是要构建一个不存于两个数组的数,所以直接将两个数组的最大值输出就是结果。

CODE:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define LL long long
#define N 110

int a[N],b[N],m,n;

int main() {
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d",&a[i]);
    scanf("%d",&m);
    for(int i = 1 ; i <= m ; i++) 
        scanf("%d",&b[i]);
    sort(a+1,a+n+1);
    sort(b+1,b+m+1);
    printf("%d %d",a[n],b[m]);
    //system("pause");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/Repulser/p/11409491.html
cf
今日推荐