该题难点在于求最小的离开数,最大的没什么好说的,关键是求最小的. 可以这样去想,最小的离开数就是每个人获得的牌数等于他所能接受的最大牌数-1,这样就可以直接比较m=a1(k1-1)+a2(k2-1)与n的大小,n-m即为最小的离开数. #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<algorithm> #include<cmath&g…
---恢复内容开始--- output standard output 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 a_1 players in the first team and a_2 players…
链接: 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…
1 Problem Description Problem 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 s…
http://codeforces.com/problemset/problem/893/D 题意 Recenlty Luba有一张信用卡可用,一开始金额为0,每天早上可以去充任意数量的钱.到了晚上,银行会对信用卡进行一次操作,操作有三种操作. 1.如果a[i]>0,银行会给卡充入a[i]元. 2.如果a[i]<0 银行从卡中扣除a[i]元. 3.如果a[i]=0 银行会查询卡里的金额. 有两条规则,如果违背信用卡就会被冻结. 1.信用卡里的金额不能大于d. 2.当银行查询卡里的金额时,金额不…
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebo…
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exactly k of t…
题目链接:http://codeforces.com/problemset/problem/93/B B. End of Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Students love to celebrate their holidays. Especially if the holiday is th…
C - Ordering Pizza CodeForces - 867C C - Ordering Pizza 这个是最难的,一个贪心,很经典,但是我不会,早训结束看了题解才知道怎么贪心的. 这个是先假设每个人都可以吃到他喜欢的,就是先求出答案,然后按照b-a 排序,分别放入两个优先队列里面, 如果b>a 那就吃第二块,否则就吃第一块,求出num,注意优先队列按照从小到达排序. num1记录第一块吃的数量,num2记录第二块吃的数量. num1%=s,num2%=s  如果num1+num2的数…
题目:http://codeforces.com/contest/570/problem/C 题意:给你一个字符串,由‘.’和小写字母组成.把两个相邻的‘.’替换成一个‘.’,算一次变换.现在给你一些个操作,操作内容是把某个位置的字符变成给定的 字符,求出每次操作后,需要多少次 变换才能把原串所有相邻的‘.’变成一个‘.’.注意,每次操作是累加的,即一次操作就会把原串替换一个字符. 分析:先求出原串的变换次数sum,然后每次询问的时候,直接看他的两边是否是".",如果是".&…