HDU 1029 Ignatius and the Princess IV(水,中位数)
来源:互联网 发布:耽美网络剧百度云链接 编辑:程序博客网 时间:2024/05/22 18:17
大概意思是有一个特殊的数字,这个数字在序列中出现(n+1)/2次..求这个数字是多少
范围是1000W...这个题排序就行了吧..竟然没有超时...因为有个数字出现了(n+1)/2次,那么无论这个数字排序后是在那个位置开始的,这个序列的中位数肯定就是这个数字...所以我们排序输出中位数即可...
不知道为何被kuangbin巨巨归到DP里面了...可能使加错了题目?
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int a[10000000];int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } sort(a,a+n); printf("%d\n",a[(n+1)/2]); } return 0;}
0 0
- HDU 1029 Ignatius and the Princess IV(水,中位数)
- hdu 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- Ignatius and the Princess IV hdu 1029
- hdu 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- HDU-1029-Ignatius and the Princess IV
- HDU--1029--Ignatius and the Princess IV
- JavaFX8初探(HTML编辑器)
- 【环境搭建】下载Spring 4的方法
- Unity3D技术之摄像机功能详解
- 简易版的suppleSlide 求助 如何简介代码
- 15个nosql数据库
- HDU 1029 Ignatius and the Princess IV(水,中位数)
- Unity3D技术入门之JavaScript
- ffmpeg实现音频resample(重采样)
- KEIL里 Volatile的用法(转)
- PHP常用函数
- 音视频 即时通讯Linux源码
- windows 不可恢复式的删除文件
- Spark 性能相关参数配置详解
- C语言变量的存储类别