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 ...
随机推荐
- 【转】阐述Handler的实现原理
面试题:阐述Handler的实现原理 2016年07月18日 21:01:35 阅读数:7574 处理过程: 从handler中获取一个消息对象,把数据封装到消息对象中,通过handler的send… ...
- 洛谷 P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers
贪婪的送礼者Greedy Gift Givers 难度:☆ Code: #include <iostream> #include <cstdio> #include <c ...
- Android ScrollView嵌套RecyclerView导致在三星s8曲面屏显示不全问题
当RecyclerView适配显示不全时可以单独给其嵌套一个相对布局!!!(必须是相对布局),这样在曲面屏手机就可以全部显示出来如下图所示 <RelativeLayout android:lay ...
- 【cpp】new delete
double *M = new double[2*num]; double *T = new double[2 * num]; double *activeM = new double[2 * num ...
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'userId' not found. Available parameters are [arg1, arg0, param1, param2]
2018-06-27 16:43:45.552 INFO 16932 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : ...
- Workrave怎么用 Workrave使用方法, Workrave 健康计时器,预防电脑长期操作的职业病伤害
下载绿色版: https://portableapps.com/apps/utilities/workrave_portable 选择阅读模式: 中文: 可以只选择启动休息的计时器,这样其他2个就不用 ...
- Pacman常用命令 文内搜索吧
列出已经安装的软件包 https://wiki.archlinux.org/index.php/Pacman_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87) 维基 pa ...
- Python基础篇 -- 字符串
字符串 字符串是不可变的对象,任何操作对原字符串是不会有任何影响的. 索引和切片 索引 . 索引就是下标, 下标从 0 开始, 使用[] 来获取数据 s1 = "0123456" ...
- Vuex基本概念
Vuex基本概念 State Getter Mutation Action Module 简单的Store import Vue from 'vue'; import Vuex from 'vuex' ...
- CSS 不换行 white-space 属性详解
实例 规定段落中的文本不进行换行: p { white-space: nowrap } 可能的值 值 描述 normal 默认.空白会被浏览器忽略. pre 空白会被浏览器保留.其行为方式类似 HTM ...