您的位置:首页 > 其它

csuoj 1390: Planting Trees

2013-08-29 08:05 127 查看
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1390

1390: Planting Trees

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 192 Solved: 115
[Submit][Status][Web Board]

Description



Input



Output



Sample Input

6
39 38 9 35 39 20

Sample Output

42

HINT



Source

AC代码:

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;

bool cmp(int a, int b)
{
return a>b;
}

int main()
{
int n, i, k, a[100010];
while(scanf("%d",&n)!=EOF)
{
for(i=0; i<n; i++)
scanf("%d",&a[i]);
sort(a, a+n, cmp);
k=0;
for(i=0; i<n; i++)
{
k=max(a[i]+i+1, k);
}
printf("%d\n", k+1);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: