B - Ignatius and the Princess IV DP
#include<iostream>
#include<vector>
using namespace std;
int cnt[];
int main()
{
int time,n,limit;
vector<int> been;
while(cin>>time)
{
int a = ;
memset(cnt,,sizeof(cnt));
limit = (time+)/;
while(time--)
{
cin>>n;
cnt[n]++;
if(cnt[n]>=limit&&a)
{
cout<<n<<endl;
a=;
}
}
}
}
普通cnt数组
DP版本:
include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
_int64 n,a;
while(scanf("%I64d",&n)!=EOF)
{
_int64 b=,c;
while(n--)
{
scanf("%I64d",&a);
if(b==)
{
c=a;
b++;
}
else
{
if(c==a)
b++;
else
b--;
}
}
printf("%I64d\n",c);
}
return ;
B - Ignatius and the Princess IV DP的更多相关文章
- HDU 1029 Ignatius and the Princess IV DP
kuangbin 专题 这题,有很多种解法. 第一种: 直接比较每个数出现次数. #include<iostream> #include<string> #include< ...
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- kuangbin专题十二 HDU1029 Ignatius and the Princess IV (水题)
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- hdu 1029 Ignatius ans the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- Ignatius and the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- Ignatius and the Princess IV(乱搞一发竟然过了)
B - Ignatius and the Princess IV Time Limit:1000MS Memory Limit:32767KB 64bit IO Format:%I64 ...
- HDU 1029 Ignatius and the Princess IV / HYSBZ(BZOJ) 2456 mode(思维题,~~排序?~~)
HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But ...
- (Arrays.sort() 或 map) Ignatius and the Princess IV hdu1029
Ignatius and the Princess IV 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 借鉴链接:https://blog.csd ...
- HDU 1029 Ignatius and the Princess IV (map的使用)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1029 Ignatius and the Princess IV Time Limit: 2000/10 ...
随机推荐
- sharePoint 2016 弃用和删除的功能
前言 sharepoint 2016版本正式发布,但是相比较2013版本,还是删除或者准备删除一些功能,我们需要了解一下哪些功能已经被删除掉或者在下一个版本中移除,因为这些可能影响我们现有系统是否能够 ...
- Android—初识AsyncTask
AsyncTask是用来处理一些后台的比较耗时的任务,给用户带来良好的体验.AsyncTask扩展Thread,增强了与主线程的交互能力. 首先介绍AsyncTask中定义的以下几个方法: onPre ...
- Set up Github Pages with Hexo, migrating from Jekyll
Set up Github Pages with Hexo, migrating from Jekyll. 本文介绍用Hexo建立github pages, 其中包含了从Jekyll迁移过来的过程. ...
- Google C++单元测试框架GoogleTest---TestFixture使用
一.测试夹具(Test Fixtures):对多个测试使用相同的数据配置 如果你发现自己写了两个或更多的测试来操作类似的数据,你可以使用测试夹具.它允许您为几个不同的测试重复使用相同的对象配置. 要创 ...
- Linux下安装tar.gz类型的jdk,并配置环境变量
近期因要学习一门技术,必须在Linux下运行,故开始学习如何使用Linux. 在安装jdk时出现了困难,环境变量配置不成功,花了一天时间才搞定,特分享出来,供大家参考. Linux下安装jdk,步骤如 ...
- MYSQL服务器my.cnf配置文档详解
MYSQL服务器my.cnf配置文档详解 硬件:内存16G [client] port = 3306 socket = /data/3306/mysql.sock [mysql] no-auto-re ...
- Tomcat中更改网站根目录
Tomcat的默认目录是指向webapps下的root目录,输入http://localhost:8080,会打开root目录下的页面.我想让localhost指向我自己的目录.比如webapps/m ...
- 关于Thinkcmf中热门文章的使用
今天在做一个首页新闻列表页面的功能时候,因为要读取大量的新闻内容列表.如果每条数据都要从数据按照文章id和term_id来对应取值,无疑是很痛苦的. 然而机智如我,发现cmf框架中热门文章的用法: 在 ...
- x01.Weiqi.9: 点目功能
添加点目功能,虽不中,不远也.还是先看看截图吧. 确保其可行,再看一张: 其点目结果,还是比较令人满意的.这主要得益于多遍扫描,如编译器的词法分析阶段,下面的代码可以证明: private void ...
- Linux下java进程CPU占用率高分析方法
Linux下java进程CPU占用率高分析方法 在工作当中,肯定会遇到由代码所导致的高CPU耗用以及内存溢出的情况.这种情况发生时,我们怎么去找出原因并解决. 一般解决方法是通过top命令找出消耗资源 ...