链接:https://codeforces.com/contest/1133/problem/C 题意: 给n个数, 在这n个数中选最多n个数,来组成一个队伍. 保证这n个数的最大最小差值不大于5. 求最多能选几个数. 思路: 排序,二分,对每个数从后往前找比他差5的第一个数. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 2e5 + 10; int a[MAXN…
Codeforces Round #544 (Div. 3) D. Zero Quantity Maximization 题目链接:https://codeforces.com/contest/1133/problem/D 题意: 给出ai,bi,然后让你确定一个数d,令ci=d*ai+bi,问怎么确定这个d,有最多的ci为0. 题解: 这个题其实不难,但是我没做起,哎,初中数学没学好啊..其实做法就是map+pair就行了. 但是这里要注意一个问题,就是当ai=bi=0的时候,d是可以任意取值…
Codeforces Round #486 (Div. 3) A. Diverse Team 题目连接: http://codeforces.com/contest/988/problem/A Description There are n students in a school class, the rating of the i-th student on Codehorses is ai. You have to form a team consisting of k students…
http://codeforces.com/contest/1133/problem/Ctime limit per test 2 secondsmemory limit per test 256 megabytesinputstandard inputoutputstandard output You are a coach at your local university. There are $n$ students under your supervision, the programm…
A. Middle of the Contest 代码: #include <bits/stdc++.h> using namespace std; int h1, m1, h2, m2; , tim2 = ; int main() { scanf("%d:%d", &h1, &m1); scanf("%d:%d", &h2, &m2); tim1 = h1 * + m1; tim2 = h2 * + m2; tim2 -…
A.Middle of the Contest 考虑把输入的时间单位化成分钟,相加除以2就好了 #include<bits/stdc++.h> using namespace std; #define re register #define sys system("pause"); inline int read(){ re ,f=;char c=getchar(); ;c=getchar();} )+(x<<)+(c^),c=getchar(); return…
题意:有\(n\)个人,每个人的能力值是\(a_i\),现在你想将这些人分成\(k\)组(没必要全选),但是每组中最高水平和最低水平的人的能力差值必须\(\le 5\),问最多能选多少人. 题解:想了一会发现纯贪心写不了,必须要用dp来求解,先排序,我们记\(dp[i,j]\),表示前\(i\)个人分成\(j\)组选的最多的人数,当便遍历到某个人的时候,他可以不加任何组\(dp[i][j]=dp[i-1][j]\),否则如果他要加入,那么我们往前找到第一个与其能力差值\(>5\)的位置\(pos…
A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lucky_ji: 水题,模拟统计A和D的数目比较大小输出结果即可 Tags: Implementation B.Anton and Digits Problems: 给定k2个2,k3个3,k5个5及k6个6,可以组成若干个32或256,求所有方案中Sigma的最大值 Analysis: lucky_ji: 同…
http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的"O"变为"X",之后会进行扫描. 扫描的规则是如果遇到一个字符为"X"并且这个字符后面的字符为"O",那么就交换. 如果哪一次扫描没有发生交换,那么扫描就停止. 现在给出的n个数字,问第一次需要扫描多少次,第二次需要扫描多少次....…
http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: n最大1e9,那么9个9最多才加81,所以最多枚举100次,就可以找到所有符合条件的数. 代码: #include <stdio.h> #include <string.h> #include <vector> using namespace std; vector<…