题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=648&page=show_problem&problem=5159

In normal football games, the winner team gets 3 points, loser team gets 0 point, and if there is a draw
game, both of the teams get 1 point.
In World Cup 1994, Group D there is an interest thing happened. There are 4 teams in that group,
Argentina, Nigeria, Bulgaria and Greece. Greece lost all the 3 matehes and scored 0. Argentina defeated
Nigeria, Nigeria defeated Bulgaria and Bulgaria defeat Argentina. Since there are only 2 teams could
advance to the next stage, one of the 3 teams will be eliminated. It’s really a surprise that a team
scored 6 will be eliminated in a 4 advance 2 group competition. That is really interesting and we’d like
to dig it deeper.
In this problem, there are N teams in a group. Within a group, any two teams will play each other
exactly once, so each team will have N − 1 matches in total.
In a match, the winner team will get A points and the loser team gets C points. If the match ends
with a draw, each of the teams gets B points. When all matches finished, the teams will be ranked by
their score (in case of multiple teams get the same score, they will be ordered randomly), and the top
M teams from the group can advance to the next stage.
Our questions are: What is the maximum possible score that a team can earn and still not advance?
(Note that there may be other teams in the same group that also earn that same score and do advance.)
Similarly, what is the minimum possible score that a team can earn and still advance?
Input
The first line of the input gives the number of test cases, T. T cases follow. Each case has two lines.
The first line contains two numbers, N and M. The second line contains three numbers, A, B, and C.
Output
For each test case, output one line containing ‘Case #x: y z’, where x is the test case number (starting
from 1) and y is maximum score that a team may be eliminated. z is the minimum score that a team
may advance to the next stage.

题目大意:一场比赛,赢的得A分,输的得C分,平手都得B分。有n支队伍,分别比赛一次,选前m个队伍晋级(分数相同的随机排名)。问:可能的最大落榜分数,可能的最小晋级分数。

思路:首先若A<C,交换A和C。

考虑第一个问题,贪心地让分数都尽量集中到前m+1个队伍身上,那么就要后n-m-1个队伍都给m+1个队伍最多的分数,即max{A, B}。

那么前m+1个队伍的竞技中,希望分数尽量地平均,则要赢一场便输一场,或者全部平手,则有floor(m/2)场得分为max{A + C, B + B}。

若m为奇数,那么最后一场要有一半的队伍获胜,或全部平手,此时最低分数为max{B, C}。

同样,考虑第二个问题,贪心得让后n-m+1的队伍分数都尽量少,那么久要前m-1个队伍给后n-m+1个队伍最少的分数,即min{B, C}。

那么后n-m+1个队伍的竞技中,也是希望分数尽量地平均,则要赢一场便输一场,或者全部平手,则有floor((n-m)/2)场得分为min{A + C, B + B}。

若n-m为奇数,那么最后一场要有一半的队伍获胜,或全部平手,此时最高分数为min{A, B}。

然后就做完了,证明我不会。

代码(0.003S):

 #ifdef OYK_JUDGE
#define longformat "%I64d"
#else
#define longformat "%lld"
#endif // OYK_JUDGE #include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL; int n, m, a, b, c, T; LL solve1() {
LL res = max(a, b) * LL(n - m - );
res += LL(m) / * max(a + c, b + b);
if(m & ) res += max(b, c);
return res;
} LL solve2() {
LL res = min(b, c) * LL(m - );
res += LL(n - m) / * min(a + c, b + b);
if((n - m) & ) res += min(a, b);
return res;
} int main() {
scanf("%d", &T);
for(int t = ; t <= T; ++t) {
scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
if(a < c) swap(a, c);
printf("Case #%d: " longformat " " longformat "\n", t, solve1(), solve2());
}
}

UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)的更多相关文章

  1. UVALive 7146 Defeat the Enemy(贪心+STL)(2014 Asia Shanghai Regional Contest)

    Long long ago there is a strong tribe living on the earth. They always have wars and eonquer others. ...

  2. UVALive 7138 The Matrix Revolutions(Matrix-Tree + 高斯消元)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  3. UVALive 7143 Room Assignment(组合数学+DP)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  4. UVALive 7141 BombX(离散化+线段树)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  5. UVALive 7139 Rotation(矩阵前缀和)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  6. UVALive 7148 LRIP(树的分治+STL)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  7. 2014 Asia AnShan Regional Contest --- HDU 5073 Galaxy

    Galaxy Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5073 Mean: 在一条数轴上,有n颗卫星,现在你可以改变k颗 ...

  8. hdu5071 2014 Asia AnShan Regional Contest B Chat

    模拟题: add的时候出现过的则不再添加 close的时候会影响到top rotate(Prior.Choose)的时候会影响到top /*============================== ...

  9. dp --- 2014 Asia AnShan Regional Contest --- HDU 5074 Hatsune Miku

    Hatsune Miku Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5074 Mean: 有m种音符(note),现在要从 ...

随机推荐

  1. dedecms中调用制定栏目

    {dede:type typeid='5'} <li> <a href="[field:typelink/]" target="_blank" ...

  2. About_PHP_文件的上传

    在form表单中,我们上传文件用的是:<input type="file" name="fileUpload" />,当然,光是这样是不行的. 我们 ...

  3. PHP中面向对象的关键字

    php面向对象中常用的关键字有final.static.const (1)final: 1,final不能修饰成员属性 2,final只能修饰类和方法 作用: 使用final修饰的类不能被子类继承 使 ...

  4. AJAX实现跨域的三种方法

    由于在工作中需要使用AJAX请求其他域名下的请求,但是会出现拒绝访问的情况,这是因为基于安全的考虑,AJAX只能访问本地的资源,而不能跨域访问. 比如说你的网站域名是aaa.com,想要通过AJAX请 ...

  5. android获取本地图片并显示图片

    import java.io.FileNotFoundException; import android.content.ContentResolver; import android.content ...

  6. java并发编程:阻塞队列

    一.几种主要的阻塞队列 自从Java 1.5之后,在java.util.concurrent包下提供了若干个阻塞队列,主要有以下几个: ArrayBlockingQueue:基于数组实现的一个阻塞队列 ...

  7. STL学习之vector

    vector是一个线性顺序结构.相当于数组,但其大小可以不预先指定,并且自动扩展.它可以像指针一样被操作,由于它的特性我们完全可以将vector看做动态数组. 特点: 1.指定一块如同数组一样的连续存 ...

  8. Moneybookers API支付方式开发 步骤

    开发文档: 支付说明手册 步骤: 1.使用商家帐号,登录到www.moneybookers.com,核对商家信息是否正确. 2.在账户-->商家工具(设置) a.API/MQI password ...

  9. [kuangbin带你飞]专题十 匹配问题 二分匹配部分

    刚回到家 开了二分匹配专题 手握xyl模板 奋力写写写 终于写完了一群模板题 A hdu1045 对这个图进行 行列的重写 给每个位置赋予新的行列 使不能相互打到的位置 拥有不同的行与列 然后左行右列 ...

  10. Ubuntu ./configure 半途终止 导致没有生成makefile文件 解决方法

    在安装thrift的时候,解压包进入目录,执行命令: ./configure 之后,发现某些包没有安装,导致configure到一半的时候退出,接着make发现没有makefile文件.估计是我系统安 ...