题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373

题目意思: 有两个class:A 和 B,Bob 在 Class A 里面。现在给出 Class A(n-1人) 和 Class B(m人) 所有人的分数,除了Bob,所以Class A 少了一个人。现在需要找出 Bob 最大可能的分数和最少可能的分数,使得他在Class A 里面拉低平均分,而在Class B 里面提高平均分。

由于数据量不大,所以可以暴力枚举。范围是两个class 中最小值和最大值之间。

这题应该是该赛区的签到题吧~~~~留个纪念^_^

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <limits.h>
#include <algorithm>
using namespace std; const int maxn = + ;
int a[maxn], b[maxn]; int main()
{
int t, n, m;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif while (scanf("%d", &t) != EOF)
{
while (t--)
{
scanf("%d%d", &n, &m);
int minn = INT_MAX, maxx = INT_MIN;
double suma = , sumb = ;
for (int i = ; i < n-; i++)
{
scanf("%d", &a[i]);
suma += a[i];
minn = min(minn, a[i]);
maxx = max(maxx, a[i]);
} for (int i = ; i < m; i++)
{
scanf("%d", &b[i]);
sumb += b[i];
minn = min(minn, b[i]);
maxx = max(maxx, b[i]);
} double avga = suma /(n-);
double avgb = sumb /m; int minans = INT_MAX, maxans = INT_MIN; for (int i = minn; i <= maxx; i++)
{
double add_suma = suma + i;
double add_sumb = sumb + i;
double new_avga = add_suma / n;
double new_avgb = add_sumb / (m+); if (new_avga < avga && new_avgb > avgb)
{
minans = min(minans, i);
maxans = max(maxans, i);
}
}
printf("%d %d\n", minans, maxans);
}
}
return ; }

2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告的更多相关文章

  1. 2014 牡丹江现场赛 i题 (zoj 3827 Information Entropy)

    I - Information Entropy Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %l ...

  2. zoj 3820(2014牡丹江现场赛B题)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...

  3. zoj 3827(2014牡丹江现场赛 I题 )

    套公式 Sample Input 33 bit25 25 50 //百分数7 nat1 2 4 8 16 32 3710 dit10 10 10 10 10 10 10 10 10 10Sample ...

  4. zoj 3819(2014牡丹江现场赛 A题 )

    题意:给出A班和B班的学生成绩,如果bob(A班的)在B班的话,两个班级的平均分都会涨.求bob成绩可能的最大,最小值. A班成绩平均值(不含BOB)>A班成绩平均值(含BOB) &&a ...

  5. 2014牡丹江 现场赛 F zoj 3824 Fiber-optic Network

    首先赞一下题目, 好题 题意: Marjar University has decided to upgrade the infrastructure of school intranet by us ...

  6. ZOJ3819 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江司A称号 Average Score 注册标题

    Average Score Time Limit: 2 Seconds      Memory Limit: 131072 KB Bob is a freshman in Marjar Univers ...

  7. ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题

    ZOJ 2819 Average Score Time Limit: 2 Sec  Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge ...

  8. ZOJ 3827 Information Entropy(数学题 牡丹江现场赛)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5381 Information Theory is one of t ...

  9. 【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829

    那天在机房做的同步赛,比现场赛要慢了一小时开始,直播那边已经可以看到榜了,所以上来就知道A和I是水题,当时机房电脑出了点问题,就慢了好几分钟,12分钟才A掉第一题... A.Average Score ...

随机推荐

  1. HTTP各个状态返回值

    转载来自于:http://desert3.iteye.com/blog/1136548 502 Bad Gateway:tomcat没有启动起来 504 Gateway Time-out: nginx ...

  2. 40.Android之新手指引界面学习

    我们经常可以看到打开新App会有新手指引界面,类似蒙板效果今天来学习.原理其实很简单,设置一个透明Activity或者Dialog,然后修改其属性即可.由于实现比较简单,就贴一部分代码. 1.在And ...

  3. TYVJ1000 A+B problem [存个高精模板]

    A+B Problem! 通过模拟我故乡非洲的计算方式,我们很快可以解决这道题. #include<iostream> #include<cstdio> #include< ...

  4. UVA 1398 Meteor

    传送门 Solution: 记一颗流星在视野内的时间段为(L, R), 为了使所有(L, R)都取整数,首先将坐标放大. 放大倍数可取为 LCM(1, 2, ..., 10)= 2520 接着计算:从 ...

  5. ExtJS入门教程03,form中怎能没有validation

    接上篇内容,我们在学会extjs form的基本用法之后,今天我们来看看extjs form的validation功能. 必填项,就是不能为空(allowBlank) 效果: 代码: { xtype: ...

  6. hdu 2046 骨牌铺方格

    #include<stdio.h> int main(void) { long long i,n,narr[55]; narr[1]=1;narr[2]=2;narr[3]=3; for( ...

  7. php实现文件安全下载

    public function downloads($name){ $name_tmp = explode("_",$name); $type = $name_tmp[0]; $f ...

  8. 可选择Email和用户名登录的代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. html中input输入框屏蔽鼠标右键

    <label> <input id="ckdestinationId" type="text" oncontextmenu="ret ...

  10. VS2013 EMMET插件学习

    在VS2013中搜索EMMET插件,安装,重启IDE,即可使用. 最简单的一个用法示例: 在编辑器里输入:ul>li*5 按快捷键:CTRL+1 即可生成如下代码: <ul> < ...