zoukankan      html  css  js  c++  java
  • Largest Point hdu 5461

    http://acm.hdu.edu.cn/showproblem.php?pid=5461

    分析:一开始很撒很撒的分了很多种情况去写了,后来发现可以先储存a*num*num和b*num的值,然后再判断最大值。。

    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <map>
    #include <queue>
    #include <stack>
    #include <math.h>
    
    using namespace std;
    
    #define met(a, b) memset(a, b, sizeof(a))
    const int maxn=5000007;
    #define oo 0x3f3f3f3f
    const int MOD = 1e9+7;
    
    typedef long long LL;
    int num[maxn];
    
    struct node
    {
        LL sum;
        int index;
    }a[maxn], b[maxn];
    
    int cmp(node p, node q)
    {
        return p.sum>q.sum;
    }
    
    int main()
    {
        int T, n, A, B, cnt=1;
        LL  num;
    
        scanf("%d", &T);
    
        while(T --)
        {
            scanf("%d %d %d", &n, &A, &B);
    
            for(int i=0; i<n; i++)
            {
                scanf("%lld", &num);
                a[i].sum=A*num*num;
                a[i].index = i;
                b[i].sum=B*num;
                b[i].index = i;
            }
    
            sort(a, a+n, cmp);
            sort(b, b+n, cmp);
    
            if(a[0].index != b[0].index)
                printf("Case #%d: %lld
    ", cnt++, a[0].sum+b[0].sum);
            else
            {
                LL p = max(a[0].sum+b[1].sum, a[1].sum+b[0].sum);
                printf("Case #%d: %lld
    ",cnt++, p);
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    windows上设置代理
    docker 代理
    windbg随笔
    win10自带ssh server使用
    centos7 最小安装后,编译配置redsocks
    cef chromium 编译
    C++中的单例模式
    delete NULL
    音视频通讯能力提供商
    云视频会议解决方案
  • 原文地址:https://www.cnblogs.com/daydayupacm/p/5761760.html
Copyright © 2011-2022 走看看