2014 ACM/ICPC Asia Regional 北京 Online
G - Grade
s = 10000 - (100 - w)^2
What’s more, Ted also has to report the mode of the grade of these mushrooms. The mode is the value that appears most often. Mode may not be unique. If not all the value are the same but the frequencies of them are the same, there is no mode.
InputThe first line of the input contains an integer T, denoting the number of testcases. Then T test cases follow.
The first line of each test cases contains one integers N (1<=N<=10^6),denoting the number of the mushroom.
The second line contains N integers, denoting the weight of each mushroom. The weight is greater than 0, and less than 200.OutputFor each test case, output 2 lines.
The first line contains "Case #x:", where x is the case number (starting from 1)
The second line contains the mode of the grade of the given mushrooms. If there exists multiple modes, output them in ascending order. If there exists no mode, output “Bad Mushroom”.Sample Input
3
6
100 100 100 99 98 101
6
100 100 100 99 99 101
6
100 100 98 99 99 97
Sample Output
Case #1:
10000
Case #2:
Bad Mushroom
Case #3:
9999 10000
这个题实际就是hash查找,单他竟然卡了cin,应该是数据加强了,或者我的算法不是很好
#include <bits/stdc++.h>
using namespace std;
int cnt[];
int main() {
int T,k=;
scanf("%d",&T);
while(T--){
memset(cnt,,sizeof(cnt));
int n;scanf("%d",&n);
for(int i=;i<n;i++){
int x;scanf("%d",&x);
cnt[-(-x)*(-x)]++;
}
int ma=INT_MIN;
for(int i=;i<=;i++)
ma=max(cnt[i],ma);
int f=;
for(int i=;i<=;i++)
if(cnt[i]&&cnt[i]<ma){
f=;break;
}
printf("Case #%d:\n",k++);
if(ma<n&&!f)printf("Bad Mushroom\n");
else{
int f1=;
for(int i=;i<=;i++){
if(cnt[i]==ma){
if(f1)printf(" ");
printf("%d",i);
f1=;
}
}
printf("\n");
}
}
return ;
}
F - Frog
The river could be considered as an axis.Matt is standing on the left bank now (at position 0). He wants to cross the river, reach the right bank (at position M). But Matt could only jump for at most L units, for example from 0 to L.
As the God of Nature, you must save this poor frog.There are N rocks lying in the river initially. The size of the rock is negligible. So it can be indicated by a point in the axis. Matt can jump to or from a rock as well as the bank.
You don't want to make the things that easy. So you will put some new rocks into the river such that Matt could jump over the river in maximal steps.And you don't care the number of rocks you add since you are the God.
Note that Matt is so clever that he always choose the optimal way after you put down all the rocks.
InputThe first line contains only one integer T, which indicates the number of test cases.
For each test case, the first line contains N, M, L (0<=N<=2*10^5,1<=M<=10^9, 1<=L<=10^9).
And in the following N lines, each line contains one integer within (0, M) indicating the position of rock.OutputFor each test case, just output one line “Case #x: y", where x is the case number (starting from 1) and y is the maximal number of steps Matt should jump.Sample Input
2
1 10 5
5
2 10 3
3
6
Sample Output
Case #1: 2
Case #2: 4
贪心下就可以了
#include <bits/stdc++.h>
using namespace std;
const int N=;
int a[N];
int main() {
int t,n,m,l,k=;
scanf("%d",&t);
while(t--) {
scanf("%d%d%d",&n,&m,&l);
for(int i=; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
int fr=,ans=,pre=-l,now;
a[n]=m;
for (int i=; i <=n; i++) {
now=a[i];
int t2=(now-fr)/(l + );
pre+=t2*(l + );
ans+=t2*;
if (now-pre>l) {
pre=fr+t2*(l+);
fr=now;
ans++;
} else fr=now;
}
printf("Case #%d: %d\n",k++,ans);
}
return ;
}
2014 ACM/ICPC Asia Regional 北京 Online的更多相关文章
- hdu 5016 点分治(2014 ACM/ICPC Asia Regional Xi'an Online)
Mart Master II Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5000 2014 ACM/ICPC Asia Regional Anshan Online DP
Clone Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/65536K (Java/Other) Total Submiss ...
- HDU 5029 Relief grain(离线+线段树+启发式合并)(2014 ACM/ICPC Asia Regional Guangzhou Online)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5029 Problem Description The soil is cracking up beca ...
- 2014 ACM/ICPC Asia Regional Shanghai Online
Tree http://acm.hdu.edu.cn/showproblem.php?pid=5044 树链剖分,区间更新的时候要用on的左++右--的标记方法,要手动扩栈,用c++交,综合以上的条件 ...
- 2014 ACM/ICPC Asia Regional Guangzhou Online
Wang Xifeng's Little Plot http://acm.hdu.edu.cn/showproblem.php?pid=5024 预处理出每个点八个方向能走的最远距离,然后枚举起点,枚 ...
- 2014 ACM/ICPC Asia Regional Anshan Online
默默的签到 Osu! http://acm.hdu.edu.cn/showproblem.php?pid=5003 #include<cstdio> #include<algorit ...
- 2014 ACM/ICPC Asia Regional Xi'an Online
03 hdu5009 状态转移方程很好想,dp[i] = min(dp[j]+o[j~i]^2,dp[i]) ,o[j~i]表示从j到i颜色的种数. 普通的O(n*n)是会超时的,可以想到o[]最大为 ...
- HDU 5010 Get the Nut(2014 ACM/ICPC Asia Regional Xi'an Online)
思路:广搜, 因为空格加上动物最多只有32个那么对这32个进行编号,就能可以用一个数字来表示状态了,因为只有 ‘P’ 'S' 'M' '.' 那么就可以用4进制刚好可以用64位表示. 接下去每次就 ...
- HDU 5002 Tree(动态树LCT)(2014 ACM/ICPC Asia Regional Anshan Online)
Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node ...
随机推荐
- Navicat for MySQL在ubuntu下运行没有反应
Step1: 打开Navicat官网,下载Navicat ,网址:http://www.navicat.com/en/download/download.html Step2:进入下载目录,解压压缩包 ...
- MyBatis框架的XML数据访问Dao层接口的组合使用
MyBatis 的前生为Apache的开源项目iBatis.其优势在于灵活,几乎可以替代JDBC,同时提供了编程接口.目前MyBatis的数据访问Dao层不需要实现类,也不需要像JDBC那样拼接Hql ...
- 优秀Java程序员的四大忌,你避免了吗?
做为一名优秀的程序员需要具备永不放弃的精神,如果一个程序员不具备这种永不放弃的精神,那么这个程序员只能算是一名假程序员.而通往成功的道路上往往是不平坦的,想要成为一个合格的高级Java程序员,需要规避 ...
- jQuery deferred应用之ajax详细源码分析(二)
在上一节中,我只贴出了$.Deferred的源码分析,并没用讲解怎么使用它,现在我们先看看$.ajax是如何使用它,让我们进行异步任务的处理. 如果没看上节的代码,请先稍微了解一下jQuery Def ...
- SP2-0734: 未知的命令开头 "imp scott/..." - 忽略了剩余的行。
Oracle数据导入报错:SP2-0734: 未知的命令开头 "imp scott/..." - 忽略了剩余的行. 原因:进入sqlplus里是不能执行imp的(sqlplus不认 ...
- bunzip2命令
bunzip2——解压缩.bz2格式文件 命令所在路径:/usr/bin/bunzip2 示例1: # bunzip2 yum.log.bz2 解压当前目录下的yum.log.bz2为yum.log, ...
- AppCrawler自动化遍历使用详解(版本2.1.0 )(转)
AppCrawle是自动遍历的app爬虫工具,最大的特点是灵活性,实现:对整个APP的所有可点击元素进行遍历点击. 优点: 1.支持android和iOS, 支持真机和模拟器 2.可通过配置来设定 ...
- 快学UiAutomator创建第一个实例
工具准备 一.准备好java环境(JDK)和安卓环境(SDK.ADT)jdk1.6+ \eclipse\SDK \ADT详情百度,安装java环境 二.打开eclipse 三.创建步骤: 右键新建== ...
- CPP-基础:字节对齐
一. 什么是字节对齐,为什么要对齐? 现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定类型变量的时候经常在特定的 ...
- 思维 || Make It Equal
http://codeforces.com/contest/1065/problem/C 题意:给你n个高度分别为a[i]的塔,每次可以横着切一刀,切掉不多于k个塔,问最少切多少刀才能把塔切的都一样高 ...