https://icpcarchive.ecs.baylor.edu/index.phpoption=com_onlinejudge&Itemid=8&page=show_problem&problem=5159

题目大意:n个队伍参加比赛,有m个队伍晋级,n个队伍有n-1场比赛,每两个队伍之间都有一场比赛。一场比赛赢的得a分,输的得c分,平局得b分,问没有晋级的队伍最高分和晋级的队伍最低分

分析:

1.没有晋级的队伍最高分

将队伍分为两堆,分别为m+1,n-m-1;令第m+1个队伍就是没晋级分数最高的队伍

第m+1个人与第二堆里面的队伍的n-m-1场比赛中得分要么每场都赢,要么每场都平局

即第m+1个人的得分: (n-m-1)*max(a, b);

贪心的让第一堆的分数高,要使第m+1个队伍就是没晋级分数最高的队伍,有两种可能

(1)第一堆m场比赛中所有队伍中每个队伍赢得场数和输的场数基本相同

即第m+1个人得分 : m/2*a+m/2*c,即m/2*(a+c);

(2)第一堆m场比赛中所有队伍都平局

即第m+1个人得分:  m/2*b+m/2*b,即m/2*(b+b);

与第一堆的比赛得分取以上两场比赛的最大值

即:max(m/2*(a+c),m/2*(b+b));

第一堆的m场比赛有可能是奇数场也有可能是偶数场,如果是奇数场那么第m+1个人的得分还得加上最后一场的得分,第一堆的最后一场比赛有可能输也有可能平局(不能赢,如果赢了那这个队就有可能比前m-1个队伍分高,就应该晋级),所以得分为max(b, c);

最终第m+1个人的得分为:

x = (n-m-1)*max(a, b)+max(m/2*a+m/2*c,m/2*b+m/2*b)

如果m为奇数x+= max(b, c);否则为x;

2.晋级的队伍最低分

将队伍分为两堆,分别为m-1,n-m+1;令第m个队伍就是晋级分数最低的队伍

第m个人与第一堆里面的队伍的m-1场比赛中得分要么每场都输,要么每场都平局

即第m个人的得分: (m-1)*min(c, b);

贪心的让第二堆的分数低,要使第m个队伍就是晋级分数最低的队伍,有两种可能

(1)第二堆n-m场比赛中所有队伍中每个队伍赢得场数和输的场数基本相同

即第m个人得分 : (n-m)/2*a+(n-m)/2*c,即(n-m)/2*(a+c);

(2)第一堆n-m场比赛中所有队伍都平局

即第m个人得分:  (n-m)/2*b+(n-m)/2*b,即(n-m)/2*(b+b);

与第一堆的比赛得分取以上两场比赛的最小值

即:min((n-m)/2*(a+c),(n-m)/2*(b+b));

第二堆的n-m场比赛有可能是奇数场也有可能是偶数场,如果是奇数场那么第m个人的得分还得加上最后一场的得分,第一堆的最后一场比赛有可能赢也有可能平局(不能输,如果输的话,那该队得的分数就比第二堆其他队的分数低就不能晋级了),所以得分为min(b, a);

最终第m个人的得分为:

x = (m-1)*min(c, b)+min((n-m)/2*(a+c),(n-m)/2*(b+b))

如果n-m为奇数x+= min(b, a);否则为x;

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm> using namespace std; typedef long long ll; int main()
{
int t;
ll n, m, a, b, c, x, y;
int p = ;
scanf("%d", &t);
while(t--)
{
p++;
x = y = ;
scanf("%lld%lld", &n, &m);
scanf("%lld%lld%lld", &a, &b, &c);
if(a < c)
swap(a, c);
x += (n - m - ) * max(a, b);
x += max(m / *(a + c), m/*(b + b));
if(m % != )
x += max(b, c);
y += (m - ) * min(b, c);
y += min((n - m) / * (a + c), (n - m) / *(b + b));
if((n - m) % != )
y += min(a, b);
printf("Case #%d: %lld %lld\n", p, x, y);
}
return ;
}

UVALive 7147 World Cup的更多相关文章

  1. UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)

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

  2. ACM学习历程—UVALive 7147 World Cup(分类讨论 && 贪心)

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

  3. UVALive 7275 Dice Cup (水题)

    Dice Cup 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/D Description In many table-top ...

  4. Gym 101194L / UVALive 7908 - World Cup - [三进制状压暴力枚举][2016 EC-Final Problem L]

    题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...

  5. UVALive - 7147 (数学)

    题目链接 题意 n只队伍,两两之间会进行比赛,赢平输都有相应得分,所有比赛结束后,前m名可以晋级.问最大的不能晋级分数为多少,以及最小的能晋级的分数. 分析 智商题...按照要求来贪心1.没有晋级的队 ...

  6. UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)

    UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There W ...

  7. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  8. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  9. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

随机推荐

  1. Hack 【二分答案】

    题意:给出n门课程,每一门课程考的分数,每一门课程的学分,求最多删去k组数据之后能够得到的最大加权平均数 先开一个数组x[],其中x[i]=1代表没有删除这门课程,x[i]=0表示删除了这门课程 然后 ...

  2. BZOJ 3668 起床困难综合症

    按位贪心. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm& ...

  3. BZOJ 1452 Count

    长知识啦..二维BIT. #include<iostream> #include<cstdio> #include<cstring> #include<alg ...

  4. 快速查询Python脚本语法

    /********************************************************************* * 快速查询Python脚本语法 * 说明: * Char ...

  5. jupyterhub

    pkill jupyterhub #激活python环境 pyenv activate jupyterhub #启动jupyterhub /fly/start_jupyterhub.sh cd ~/r ...

  6. console.log的一个应用 -----用new方法生成一个img对象和document.createElement方法创建一个img对象的区别

    我用两种方法来生成img对象,第一种方法是用new方法,第二种方法是用document.createElement方法. var img1 = new Image(); var img2 = docu ...

  7. 20160129.CCPP体系详解(0008天)

    程序片段(01):函数.c+call.c+测试.cpp 内容概要:函数 ///函数.c #include <stdio.h> #include <stdlib.h> //01. ...

  8. 【C#学习笔记】改变颜色

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. 【转】iOS开发-Protocol协议及委托代理(Delegate)传值

    原文网址:http://www.cnblogs.com/GarveyCalvin/p/4210828.html 前言:因为Object-C是不支持多继承的,所以很多时候都是用Protocol(协议)来 ...

  10. sort方法的使用、随机数的产生

    如果调用该方法时没有使用参数,将按字母顺序对数组中的元素进行排序,说得更精确点,是按照字符编码的顺序进行排序. var arr = ['a','b','m','c','d']; arr.sort(); ...