题解 CF934A 【A Compatible Pair】

其实原本是想用贪心去做的,但是因为涉及到负数乘法,麻烦一些,只好暴力了

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

bool cmp(int x, int y)
{
    return x > y;
}

bool cmp2(int x, int y)
{
    return x < y;
}

long long a[55], b[55];

int main()
{
    long long n, m, cnt = 0, cnt2 = 0, max = -0x7fffffffffffffff, ans = 0x7fffffffffffffff;//无穷大和无穷小
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 1; i <= m; i++)
    {
        cin >> b[i];
    }
    for(int i = 1; i <= n; i++)
    {
        max = -0x7fffffffffffffff;
        for(int j = 1; j <= n; j++)
        {
            if(i != j)
            {
                for(int x = 1; x <= m; x++)
                {
                    max = a[j] * b[x] > max ? a[j] * b[x] : max;
                }
            }
        }
        ans = max < ans ? max : ans;
    }
    cout << ans << endl;
    return 0;
}
posted @   HappyBobb  阅读(9)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示