【2015ZUFE新生赛网络同步赛C】【水题 贪心】boom x乘(y+z)尽可能大
2015-12-07 12:15
477 查看
#include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include<bitset> #include<algorithm> #include<time.h> using namespace std; void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);} #define MS(x,y) memset(x,y,sizeof(x)) #define MC(x,y) memcpy(x,y,sizeof(x)) #define MP(x,y) make_pair(x,y) #define ls o<<1 #define rs o<<1|1 typedef long long LL; typedef unsigned long long UL; typedef unsigned int UI; template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;} template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;} const int N=0,M=0,Z=1e9+7,ms63=1061109567; int casenum,casei; int n; int a[1010]; int main() { while(~scanf("%d",&n)) { for(int i=1;i<=n;++i)scanf("%d",&a[i]); sort(a+1,a+n+1); printf("%lld\n",LL(a )*(a[n-1]+a[n-2])); } return 0; } /* 【trick&&吐槽】 乘法肯定要小心爆int啦! 【题意】 让你从n(3<=n<=1000)个数中选出3个数,x,y,z,使得x*(y+z)尽可能大。 并输出这个max(x*(y+z)) 【类型】 贪心 【分析】 显然x,y,z是前三大的数,而且x最大。 */
相关文章推荐
- HDU 5240 Exam (好水的题)
- 北大—1006——Biorhythms
- 时间计算(heaven.pas/cpp)
- 工作依赖(job.cpp/pas)
- 题目 英雄 (BFS)
- kmp 学习 hihocoder #1015
- HDU 1096 A+B for Input-Output Practice (VIII)
- P1478
- P1035
- P1008 难度2.7
- 2020 绝对值排序
- 2021 发工资咯
- 2022 海选女主角
- 2024 C语言合法标识符
- 2025 查找最大元素
- 2026 首字母变大写
- 2027 统计元音
- 2028 Lowest Common Multiple Plus
- 2018 母牛的故事
- 2023 求平均成绩