2014ACM/ICPC亚洲区域赛牡丹江站现场赛-A ( ZOJ 3819 ) Average Score
Average Score
Time Limit: 2 Seconds Memory Limit: 65536 KB
Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis.
After a mid-term exam, Bob was anxious about his grade. He went to the professor asking about the result of the exam. The professor said:
"Too bad! You made me so disappointed."
"Hummm... I am giving lessons to two classes. If you were in the other class, the average scores of both classes will increase."
Now, you are given the scores of all students in the two classes, except for the Bob's. Please calculate the possible range of Bob's score. All scores shall be integers within [0, 100].
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains two integers N (2 <= N <= 50) and M (1 <= M <= 50) indicating the number of students in Bob's class and the number
of students in the other class respectively.
The next line contains N - 1 integers A1, A2, .., AN-1 representing the scores of other students in Bob's
class.
The last line contains M integers B1, B2, .., BM representing the scores of students in the other class.
Output
For each test case, output two integers representing the minimal possible score and the maximal possible score of Bob.
It is guaranteed that the solution always exists.
Sample Input
2
4 3
5 5 5
4 4 3
6 5
5 5 4 5 3
1 3 2 2 1
Sample Output
4 4
2 4
Author: JIANG, Kai
Source: The 2014 ACM-ICPC Asia Mudanjiang Regional Contest
题目链接:Average Score
解题思路:牡丹江站的签到题!!
!好恶心,当时在现场,好像快一个小时的时候才出题。太菜了。。。開始还没想到简单的方法,想直接暴力枚举,后来又想了想,直接计算出A班的n-1个人的平均成绩,然后取下界。这就是分数的最大值。再求B班的m个人的平均成绩,取上界。这就是分数的下界。
AC代码:
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define INF 0x7fffffff int main()
{
#ifdef sxk
freopen("in.txt","r",stdin);
#endif
int T, n, m, sum, c;
scanf("%d",&T);
while(T--)
{
sum = 0;
scanf("%d%d",&n,&m);
for(int i=0; i<n-1; i++){
scanf("%d", &c);
sum += c;
}
double ans1 = 1.0*sum/(n-1);
if(floor(ans1) == ans1) ans1 --;
else ans1 = floor(ans1); //取下界
sum = 0;
for(int i=0; i<m; i++){
scanf("%d", &c);
sum += c;
}
double ans2 = 1.0*sum/m;
if(floor(ans2) == ans2) ans2 ++; //取上界
else ans2 = ceil(ans2);
cout<<ans2<<" "<<ans1<<endl;
}
return 0;
}
2014ACM/ICPC亚洲区域赛牡丹江站现场赛-A ( ZOJ 3819 ) Average Score的更多相关文章
- 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-K ( ZOJ 3829 ) Known Notation
Known Notation Time Limit: 2 Seconds Memory Limit: 65536 KB Do you know reverse Polish notation ...
- 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-I ( ZOJ 3827 ) Information Entropy
Information Entropy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Information ...
- ZOJ 3819 Average Score(数学 牡丹江游戏网站)
主题链接:problemId=5373">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Bob is ...
- 2014ACM/ICPC亚洲区域赛牡丹江站汇总
球队内线我也总水平,这所学校得到了前所未有的8地方,因为只有两个少年队.因此,我们13并且可以被分配到的地方,因为13和非常大的数目.据领队谁oj在之上a谁去让更多的冠军.我和tyh,sxk,doub ...
- 2014ACM/ICPC亚洲区域赛牡丹江现场赛总结
不知道怎样说起-- 感觉还没那个比赛的感觉呢?如今就结束了. 9号.10号的时候学校还评比国奖.励志奖啥的,由于要来比赛,所以那些事情队友的国奖不能答辩.自己的励志奖班里乱搞要投票,自己又不在,真是无 ...
- 2015 ACM / ICPC 亚洲区域赛总结(长春站&北京站)
队名:Unlimited Code Works(无尽编码) 队员:Wu.Wang.Zhou 先说一下队伍:Wu是大三学长:Wang高中noip省一:我最渣,去年来大学开始学的a+b,参加今年区域赛之 ...
- 2013ACM/ICPC亚洲区南京站现场赛---Poor Warehouse Keeper(贪心)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4803 Problem Description Jenny is a warehouse keeper. ...
- 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)
摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...
- 2016ACM/ICPC亚洲区大连站现场赛题解报告(转)
http://blog.csdn.net/queuelovestack/article/details/53055418 下午重现了一下大连赛区的比赛,感觉有点神奇,重现时居然改了现场赛的数据范围,原 ...
随机推荐
- python基础复习-1-2 数据类型-str、list、tuple、dict
数据类型 数字 引号: 123 数值 '123' 字符串 整数:ini long 范围:(-2**31 - 2**31) num = 123 长整型 long (L) num = 123L 浮点型:f ...
- javascript中a标签把href属性设置为“javascript:void(0)”还是会打开空白页面的问题
在项目中有个位置的点击a标签这里要加一个权限判断,但是之前使用的是js动态添加a标签,href的属性值是一个url,但是我要做权限判断之后,我的url就不能设置在href属性中了,这样的话我可以在a标 ...
- hdu 5748(LIS)
Bellovin Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- linux+win7双系统重装win7修复grub的办法
本人是debian+win7的双系统, 下面介绍下重装win7的整个过程以及遇到的一些小问题,在查阅相关博客和朋友的帮助下成功修复, 记录下以便以后有不时之需, 也希望能帮助到遇到同样问题的朋友! 首 ...
- 部署web应用到虚拟主机的三种方式
方式一: 在 [tomcat]/conf/server.xml 文件中的<Engine>标签下的<Host>标签内部, 添加一个 <Context ...
- Rescue The Princess
Description Several days ago, a beast caught a beautiful princess and the princess was put in prison ...
- thinkphp函数学习(1)——header, get_magic_quotes_gpc, array_map, stripslashes, stripslashes_deep
1. header 相关语句 header('Content-type: text/html; charset=utf-8'); // 因为这是在TP的入口文件中,所以每个页面返回的http head ...
- [thinkphp] 公共头部底部如何传递数据
分组底下有一个公共模板文件夹 Modules/Index/Tpl/public/ 如何传递数据给模板呢? 在 入口文件/Lib/Action/ 中创建类CommonAction.class.php ...
- HDU 多校1.11
- Python3 list记录
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author;Tsukasa name = ['YangJiaHui','LiuYueEr','TaB ...