hdu 1800 - Flying to the Mars
来源:互联网 发布:java电信项目 编辑:程序博客网 时间:2024/06/03 13:50
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800
题意:
有n个士兵每个人有一个能力值d,现在士兵要去学习如何飞到火星。规定如下,能力值大的可以教能力值小的,
每个人只能够教一个人。规定一起学习的人的书本是一样的,问最少需要几本书?
思路:
根据题目的意思是我们可以知道最终要求的就是有几个递减的序列,也就是找到最多重复的值。比如2 3 4 3 4 就是两个递减序列4 3 2 和 4 3。重复的数有3,4;即输出2个。
这道题就变成寻找一组数中重复出现的数的个数。
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include<stack>using namespace std;int a[3010];int main(){ int n; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); int i,j; for(i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n); int count=1; int MAX=1; for(i=1;i<n;i++) { if(a[i]>a[i-1]) { count=1; } else { count++; if(count>MAX) { MAX=count; } } } printf("%d\n",MAX); } return 0;}
0 0
- Flying to the Mars (hash) 1800 hdu
- hdu 1800 Flying to the Mars
- Hdu-1800 Flying to the Mars
- hdu 1800 Flying to the Mars
- hdu 1800 Flying to the Mars
- HDU-1800-Flying to the Mars
- hdu 1800 Flying to the Mars
- hdu 1800 Flying to the Mars
- hdu 1800 Flying to the Mars
- HDU 1800 Flying to the Mars
- HDU 1800 Flying to the Mars STL
- HDU -1800 Flying to the Mars
- hdu - 1800 - Flying to the Mars
- HDU 1800 Flying to the Mars(trie)
- HDU--1800 -- Flying to the Mars
- HDU-1800 - Flying to the Mars
- hdu 1800 Flying to the Mars【水水】
- HDU 1800 Flying to the Mars
- (Apache服务)修改服务可执行路径
- Java中的反射
- Struts2学习笔记(十一)命名空间
- SyntaxError: Non-ASCII character '\xe8' in file
- 学会这几个.你就能成为bat脚本小子了...(转来看看的)
- hdu 1800 - Flying to the Mars
- 2812:信息分割
- 安卓面试题系列-4
- 2015年腾讯暑期实习面试
- 禁止网页内容复制、另存为、粘贴的简单方案
- Swing做一个类似红绿灯的东西
- qml+QZXing实现实时QRCode识别和给重复造轮子的一些建议
- JMS初识
- Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() inst