链接:

https://codeforces.com/contest/1215/problem/A

题意:

The final match of the Berland Football Cup has been held recently. The referee has shown n yellow cards throughout the match. At the beginning of the match there were a1 players in the first team and a2 players in the second team.

The rules of sending players off the game are a bit different in Berland football. If a player from the first team receives k1 yellow cards throughout the match, he can no longer participate in the match — he's sent off. And if a player from the second team receives k2 yellow cards, he's sent off. After a player leaves the match, he can no longer receive any yellow cards. Each of n yellow cards was shown to exactly one player. Even if all players from one team (or even from both teams) leave the match, the game still continues.

The referee has lost his records on who has received each yellow card. Help him to determine the minimum and the maximum number of players that could have been thrown out of the game.

思路:

最少的就是先给每个人k-1张, 再慢慢补, 最多的就是贪心给, 先给k小的.

代码:

#include <bits/stdc++.h>
using namespace std; int main()
{
int a1, a2, k1, k2, n;
cin >> a1 >> a2 >> k1 >> k2 >> n;
if (k1 > k2)
swap(a1, a2), swap(k1, k2);
int sum = a1*(k1-1)+a2*(k2-1);
int small = max(0, min(a1+a2, n-sum));
int cnta = min(a1, n/k1);
n -= cnta*k1;
int cntb = min(a2, n/k2);
cout << small << ' ' << cnta+cntb << endl; return 0;
}

Codeforces Round #585 (Div. 2) A. Yellow Cards(数学)的更多相关文章

  1. Codeforces Round #376 (Div. 2) F. Video Cards 数学,前缀和

    F. Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  2. Codeforces Round #376 (Div. 2) F. Video Cards 数学 & 暴力

    http://codeforces.com/contest/731/problem/F 注意到一个事实,如果你要找一段区间中(从小到大的),有多少个数是能整除左端点L的,就是[L, R]这样.那么,很 ...

  3. A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题

    ---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recent ...

  4. Codeforces Round #585 (Div. 2)

    https://www.cnblogs.com/31415926535x/p/11553164.html 感觉很硬核啊这场,,越往后越做不动,,,emmmm,,,(这场是奔着最后一题 2sat 来的, ...

  5. Codeforces Round #585 (Div. 2) [补题]

    前言 2019.9.16 昨天下午就看了看D题,没有写对,因为要补作业,快点下机了,这周争取把题补完. 2019.9.17 这篇文章或者其他文章难免有错别字不被察觉,请读者还是要根据意思来读,不要纠结 ...

  6. Codeforces Round #585 (Div. 2) CF1215A~C

    CF1215A. Yellow Cards简单的模拟,给定了黄票张数,判断最少和最多有多少人被罚下场. #include <bits/stdc++.h> using namespace s ...

  7. Codeforces Round #376 (Div. 2) F. Video Cards —— 前缀和 & 后缀和

    题目链接:http://codeforces.com/contest/731/problem/F F. Video Cards time limit per test 1 second memory ...

  8. Codeforces Round #376 (Div. 2)F. Video Cards(前缀和)

    题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的 ...

  9. Codeforces Round #585 (Div. 2) D. Ticket Game

    链接: https://codeforces.com/contest/1215/problem/D 题意: Monocarp and Bicarp live in Berland, where eve ...

随机推荐

  1. 获取Android手机日志

    方式一:使用USB连接 1.在手机上启用USB调试2.在终端输入adb devices 3.获取日志 只连接一个设备:1)清除已缓存日志:adb logcat -c2)获取日志并保存到本地:adb l ...

  2. java日志框架系列(4):logback框架xml配置文件语法

    1.xml配置文件语法 由于logback配置文件语法特别灵活,因此无法用DTD或schema进行定义. 1.配置文件基本结构 配置文件基本结构:以<configuration>标签开头, ...

  3. zabbix硬件监控以及服务

    大家好今天给大家带来zabbix3.4.8监控主机,那么最近由于我个人的关系.没有及时的更新文章所以,很抱歉那么今天我分享的内容是zabbix3.4.8监控服务器.本章的具体监控服务器如下: 服务器的 ...

  4. C#基础算法题 找出最大值和最小值

    找出最大值和最小值 题目要求 输入n个数,n<=100,找到其中最小的数和最大的数 实现代码 using System; namespace _1.求最大最小 { class Program { ...

  5. (转)从0移植uboot (一) _配置分析

    ref : https://www.cnblogs.com/xiaojiang1025/p/6106431.html 本人建议的uboot学习路线,先分析原有配置,根据现有的配置修改.增加有关的部分, ...

  6. Luogu5284 十二省联考2019字符串问题(后缀树+拓扑排序)

    对反串建SAM弄出后缀树,每个b串通过倍增定位其在后缀树上对应的节点,根据其长度将节点拆开.然后每个a串也找到对应的节点,由该节点向表示a串的节点连边,再把所给的边连上跑拓扑排序即可. #includ ...

  7. hdu 6216 A Cubic number and A Cubic Number

    题意:给定一个素数,判定它是不是两个立方数之差. 题解:对于a^3+b^3=(a-b)(a^2-a*b+b^2),而一个素数的因子只有1和其本身,在加上(a^2-a*b+b^2)一定是大于1的,所以只 ...

  8. (五)Activiti之查看最新版本的流程定义

    一.查看最新版本的流程定义 因为每个流程定义都可能会有好几个版本,所以有时候我们有这样的需求,查询出最新版本的流程定义的集合 第一步:我们通过Activiti接口来获取根据流程定义Version升序排 ...

  9. Java MergeSort

    Java MergeSort /** * <html> * <body> * <P> Copyright 1994-2018 JasonInternational ...

  10. 奇妙的算法【6】-WY回文、树、最优化、卷积判断

    1,判断一个十进制正整数的二进制数是否为回文 package com.cnblogs.mufasa.answer1; import java.util.Scanner; public class Ma ...