2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告
题目链接: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) 解题报告的更多相关文章
- 2014 牡丹江现场赛 i题 (zoj 3827 Information Entropy)
I - Information Entropy Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %l ...
- zoj 3820(2014牡丹江现场赛B题)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...
- 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 ...
- zoj 3819(2014牡丹江现场赛 A题 )
题意:给出A班和B班的学生成绩,如果bob(A班的)在B班的话,两个班级的平均分都会涨.求bob成绩可能的最大,最小值. A班成绩平均值(不含BOB)>A班成绩平均值(含BOB) &&a ...
- 2014牡丹江 现场赛 F zoj 3824 Fiber-optic Network
首先赞一下题目, 好题 题意: Marjar University has decided to upgrade the infrastructure of school intranet by us ...
- ZOJ3819 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江司A称号 Average Score 注册标题
Average Score Time Limit: 2 Seconds Memory Limit: 131072 KB Bob is a freshman in Marjar Univers ...
- ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题
ZOJ 2819 Average Score Time Limit: 2 Sec Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge ...
- ZOJ 3827 Information Entropy(数学题 牡丹江现场赛)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5381 Information Theory is one of t ...
- 【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829
那天在机房做的同步赛,比现场赛要慢了一小时开始,直播那边已经可以看到榜了,所以上来就知道A和I是水题,当时机房电脑出了点问题,就慢了好几分钟,12分钟才A掉第一题... A.Average Score ...
随机推荐
- ubuntu14.10建立热点wifi分享给手机
http://jingyan.baidu.com/article/363872ecd8f35d6e4ba16f97.html ubuntu14.10建立热点wifi分享给手机
- 【bzoj4010】 HNOI2015—菜肴制作
http://www.lydsy.com/JudgeOnline/problem.php?id=4010 (题目链接) 题意 给出一张无向图要求出一个拓扑序列满足1的位置最靠前 ,在保证上面的条件下使 ...
- BZOJ3098 Hash Killer II
Description 这天天气不错,hzhwcmhf神犇给VFleaKing出了一道题: 给你一个长度为N的字符串S,求有多少个不同的长度为L的子串. 子串的定义是S[l].S[l + 1].... ...
- BZOJ3720 Gty的妹子树
Description 我曾在弦歌之中听过你, 檀板声碎,半出折子戏. 舞榭歌台被风吹去, 岁月深处尚有余音一缕…… Gty神(xian)犇(chong)从来不缺妹子…… 他来到了一棵妹子树下,发现每 ...
- JBoss7.1配置外网访问
在JBoss7.1目录jboss-as-7.1.1.Final/standalone/configuration下找到standalone.xml,找到以下的节点,在尝试了以下两种方法: 1. < ...
- Serverlet程序
Serverlet是用Java编写的服务器端程序;主要用于交互地浏览和修改数据,生成动态Web内容; 一个serverlet就是一个继承于HttpServlet抽象类的Java类:下面先看一个简单的例 ...
- spring 标注 详解
http://snowolf.iteye.com/blog/578452 http://snowolf.iteye.com/blog/578452 非常棒的入门读物
- C# 根据IP地址获取城市
using System; using System.IO; using System.Net; using System.Text; using System.Web.Script.Serializ ...
- JS 省,市,区
// 纯JS省市区三级联动 // 2011-11-30 by http://www.cnblogs.com/zjfree var addressInit = function (_cmbProvinc ...
- prob
void calc_probability(int num) { , j = , k = ; #define SIZE_NUM 8 int *array_num = NULL; int *rememb ...