D. Renting Bikes 读懂题后一开始和队友都以为是贪心.可是贪心又怎么贪呢..我们无法确定到底能买多少车但肯定是最便宜的前x辆.除了公共预算每个人的钱只能自己用,也无法确定每个人买哪一辆车..比赛快结束时我去看最后一题,队友还在 想,突然他想到了用二分的思路,然后验证了一下是正确的,但时间不够了.今天回来就这道题都快写了两小时了. 题意:n个人,每个人自己有一定的钱,还有公共的预算.m辆自行车,每辆车有一定的价格.求最多能租几辆车并且用的私房钱的总数最少. 思路:结束后百度了一下果然…
---恢复内容开始--- 题目地址 简要题意: n个小伙子一起去买自行车,他们有每个人都带了一些钱,并且有公有的一笔梦想启动资金,可以分配给任何小伙子任何数值,当然分配权在我们的手中.现在给出m辆自行车的价格,需要你求出最多可以让多少个小伙子有属于自己的自行车(即自行车不可以两个人共有,只能一个人有),和在满足之前这个条件的情况下,通过最省私人钱的分配,最少需消耗多少私人的资金. 思路分析: 首先考虑,如何分配才是使其中x个小伙子能有自己车的最好分配方法.不难想到,将n个小伙子按个人资金从大到小…
难得一次比赛能够自己成功A掉四个题: A题:水题,模拟一下就行: #include <iostream> #include <cstdio> using namespace std; void print(int x) { ){printf(;} else printf("O-|"); )puts("-OOOO"); )puts("O-OOO"); )puts("OO-OO"); )puts("…
B. Fence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from lef…
题目链接:http://codeforces.com/problemset/problem/675/D 给你一个如题的二叉树,让你求出每个节点的父节点是多少. 用set来存储每个数,遍历到a[i]的时候查找比a[i]大的数的位置,然后插入,而父亲就是刚好比a[i]小的数或刚好大的数. 然后讨论是哪一个数. 比如给你3 1 2 ,如图 1的父亲是3 ,2的父亲是1. 那我其实只要找左边或右边出现最晚的数就行了,用pair的first表示a[i],second表示出现的顺序i. #include <…
题目链接:http://codeforces.com/contest/672/problem/D 有n个人,k个操作,每个人有a[i]个物品,每次操作把最富的人那里拿一个物品给最穷的人,问你最后贫富差距有多少. 先sort一下,最富的人很明显不会低于sum(a1 ~ an) / n , 所以二分一下最富人的最小值 看是否满足操作k. 最穷的人不会高于sum(a1 ~ an) / n + 1 ,所以二分一下最穷人的最大值 看是否满足操作k. (注意一点的是二分以后最穷的人的最大值和最富的人的最小值…
B. More Cowbell Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/B Description Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of co…
B. Nearest Fraction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/281/problem/B Description You are given three positive integers x, y, n. Your task is to find the nearest fraction to fraction  whose denominator is no mor…
C. Read Time Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/C Description Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can read data i…
题目链接:http://codeforces.com/problemset/problem/460/C C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subjec…
B. Robin Hood 题目连接: http://www.codeforces.com/contest/671/problem/B Description We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citiz…
B. Skills 题目连接: http://www.codeforces.com/contest/613/problem/B Description Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly…
原题链接:http://codeforces.com/contest/580/problem/B 题意: 给你一个集合,集合中的每个元素有两个属性,$m_i,s_i$,让你求个子集合,使得集合中的最大m的差不超过d的情况下,s的和的最大值. 题解: 先排序,然后对于a[i],直接二分a[i].s+d的位置,然后维护一个前缀和,更新答案即可. 代码: #include<iostream> #include<cstring> #include<algorithm> #inc…
题意: 两个人比赛,给出比赛序列,如果为1,说明这场1赢,为2则2赢,假如谁先赢 t 盘谁就胜这一轮,谁先赢 s 轮则赢得整个比赛.求有多少种 t 和 s 的分配方案并输出t,s. 解法: 因为要知道有哪些t,s,那么我们至少要枚举一个量,然后才能得出所有分配方案,由题意似乎枚举 t 比较方便.由于 n <= 10^5, 那么我们必须在平均logn算法级以下判断此 t 合不合法,即有没有合法的 s .经过一些预处理,或者二分都可以达到logn的算法. 预处理sum1[i], sum2[i] 分别…
题目链接 这题,关键不是二分,而是如果在t的时间内,将n个头,刷完这m个磁盘. 看了一下题解,完全不知怎么弄.用一个指针从pre,枚举m,讨论一下.只需考虑,每一个磁盘是从右边的头,刷过来的(左边来的之前刷了). 思维是硬伤. #include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <algori…
D. Robin Hood   We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood…
A. Anton and Polyhedrons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:…
A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly k time u…
E. Product Sum   Blake is the boss of Kris, however, this doesn't spoil their friendship. They often gather at the bar to talk about intriguing problems about maximising some values. This time the problem is really special. You are given an array a o…
题意:对于一个数\(x\),有函数\(f(x)\),如果它是偶数,则\(x/=2\),否则\(x-=1\),不断重复这个过程,直到\(x-1\),我们记\(x\)到\(1\)的这个过程为\(path(x)\),它表示这个过程中所有\(x\)的值,现在给你一个数\(n\)和\(k\),要你找出最大的数\(x\),并且\(x\)在\(path[1,n]\)中出现的次数不小于\(k\). 题解:我们对于\(x\)可以选择分奇偶来讨论. 1.假如\(x\)为奇数,那么根据题意,我们知道\(x,2x,2x…
题意:有长度\(n\)的序列,让你构造序列,使得二分查找能在\(pos\)位置找到值\(x\).问最多能构造出多少种排列? 题解:题目给出的\(pos\)是固定的,所以我们可以根据图中所给的代码来进行二分,确定有多少数小于\(x\)和大于\(x\),然后根据排列组合即可算出答案. 代码: int n,x,pos; ll fac[N]; ll f[N],invf[N]; ll fpow(ll a,ll k){ ll res=1; while(k){ if(k&1) res=(res*a)%mod;…
题意:有个\(n\)个公寓,每个公寓\(a_{i}\)代表着编号为\(1-a_{i}\)个房间,给你房间号,问它在第几栋公寓的第几个房间. 题解:对每个公寓的房间号记一个前缀和,二分查找属于第几个公寓,然后求个差即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <sta…
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help. Vasiliy is given n strings consisting of lowercase Engl…
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bough…
[Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more than \(\frac{n \cdot (n-1)}{2}-1\) exchange operations, he won't do this boring work." 例如:5,4,3,2,1 我们需要移动4+3+2+1=10次,也就是\(\frac{n \cdot (n-1)}{2}\)次,所以…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…