[ACM] 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
解题思路:
题意为 bob所在的班有n个人,每人都有一个成绩,另外一个班有m个人。没人都有一个成绩,假设把bob放到还有一个班里去。那么两班的平均分都比原来的班内平均分要高,问符合条件的bob的成绩的范围。
枚举就可以。
代码:
#include <iostream>
#include <cmath>
using namespace std;
int t;
double a[52];
double b[52];
int n,m;
int bob;
int s,e; int main()
{
cin>>t;
while(t--)
{
cin>>n>>m;
double sum1=0.0;
double sum2=0.0;
double pre1,pre2;
for(int i=1;i<=n-1;i++)
{
cin>>a[i];
sum1+=a[i];
}
for(int i=1;i<=m;i++)
{
cin>>b[i];
sum2+=b[i];
}
bool first=0;
for(bob =0;bob<=100;bob++)
{
pre1=(sum1+bob)/n;
pre2=(sum2)/m;
if((sum1)/(n-1)>pre1&&(sum2+bob)/(m+1)>pre2)
{
if(first)
e=bob;
if(!first)
{
s=bob;
e=bob;
}
first=1;
} }
cout<<s<<" "<<e<<endl;
}
return 0;
}
[ACM] ZOJ 3819 Average Score (水题)的更多相关文章
- ZOJ 3819 Average Score 水
水 Average Score Time Limit: 2 Seconds Memory Limit: 65536 KB Bob is a freshman in Marjar Univer ...
- ZOJ 3819 Average Score(平均分)
Description 题目描述 Bob is a freshman in Marjar University. He is clever and diligent. However, he is n ...
- zoj 3819 Average Score
Average Score Time Limit: 2 Seconds Memory Limit: 65536 KB Bob is a freshman in Marjar Universi ...
- ZOJ 3819 Average Score(数学 牡丹江游戏网站)
主题链接:problemId=5373">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Bob is ...
- ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题
ZOJ 2819 Average Score Time Limit: 2 Sec Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge ...
- UVa 1585 Score --- 水题
题目大意:给出一个由O和X组成的串(长度为1-80),统计得分. 每个O的分数为目前连续出现的O的个数,例如,OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3 解题思路:用一个变量t ...
- hdu 5268 ZYB loves Score 水题
ZYB loves Score Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- ZOJ 3827 Information Entropy 水题
Information Entropy Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/sh ...
- 咸鱼的ACM之路:DFS水题集
DFS的核心就是从一种状态出发,转向任意的一个可行状态,直到达到结束条件为止.(个人理解) 下面全是洛谷题,毕竟能找到测试点数据的OJ我就找到这一个....在其他OJ上直接各种玄学问题... P159 ...
随机推荐
- Maven+Docker,发布到Registry
1.配置Pom.xml <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEnc ...
- [转]Linux rpm 命令参数使用详解
转自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/08/2203153.html RPM是RedHat Package Mana ...
- Hadoop Hive概念学习系列之hive的脚本执行(二十)
相当一部分人,容易忽略hive脚本,其实,这在生产环境里,是非常重要的! $ hive -e "show tables" $ hive -e "show tables & ...
- Laravel5.1学习笔记13 系统架构5 Contract
Contract 简介 为什么要用 Contract? Contract 参考 如何使用 Contract 简介 Laravel 中的 Contract 是一组定义了框架核心服务的接口.例如,Illu ...
- 【java并发容器】并发容器之CopyOnWriteArrayList
原文链接: http://ifeve.com/java-copy-on-write/ Copy-On-Write简称COW,是一种用于程序设计中的优化策略.其基本思路是,从一开始大家都在共享同一个内容 ...
- win32之bitmap篇
先讲一下LoadBitmap的用法,代码如下: PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd,&ps); HDC hMemDC = CreateCompa ...
- CSS——行高
浏览器默认文字大小:16px 行高:是基线与基线之间的距离 行高=文字高度+上下边距 一行文字行高和父元素高度一致的时候,垂直居中显示. <!DOCTYPE html> <html& ...
- JSP中如何利用JS实现登录页面的跳转(JSP中如何利用JS实现跳转页面)
<%! <% url = word = } ...
- 如何设置“用eclipse开发时自动在顶端产生import”?
eclipse新版本中的默认设置可能导致自动在生成import时是在代码中,而大多数时间我们需要自动生成import在代码顶端,按照如下设置即可纠正
- 12--c完数/最大公约数/最小公倍数/素数/回文数
完数/最大公约数/最小公倍数/素数/回文数 2015-04-08 10:33 296人阅读 评论(0) 收藏 举报 分类: C/C++(60) 哈尔滨工业大学(8) 版权声明:本文为博主原创文章 ...