Description
一次箱子里有n种颜色的球,第i种颜色球有a[i]个,现在可以选出一个球得知其数量,之后会从箱子里一个个把所有球都拿出来要猜其颜色,让最坏情况下猜对的次数最大
Input
第一行一整数n表示球的颜色数量,之后n个整数a[i]表示第i种颜色的小球数量(1<=n<=2e5,1<=a[i]<=1e9)
Output
输出最坏情况下猜对的最多次数
Sample Input
4
5 2 2 9
Sample Output
9
Solution
求出a[i]的最大值即可
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define maxn 1111
int n,a,Max;
int main()
{
while(~scanf("%d",&n))
{
Max=0;
while(n--)
{
scanf("%d",&a);
Max=max(Max,a);
}
printf("%d\n",Max);
}
return 0;
}