B. School Marks Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/problem/B Description Little Vova studies programming in an elite school. Vova and his classmates are supposed to write n progress tests, for each test the…
题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的numy是最少需要的,这样才可能中位数大于等于y */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> using namespace std; ; con…
其实是很水的一道bfs题,昨晚比赛的时候没看清题意,漏了一个条件. #include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<set> #include<map> #include<queue> #include<stack> #include<strin…
题目传送门 /* 题意:告诉起点终点,踩一次, '.'变成'X',再踩一次,冰块破碎,问是否能使终点冰破碎 DFS:如题解所说,分三种情况:1. 如果两点重合,只要往外走一步再走回来就行了:2. 若两点相邻, 那么要不就是踩一脚就破了或者踩一脚走开再走回来踩一脚破了:3. 普通的搜索看是否能到达, 若能还是要讨论终点踩几脚的问题:) DFS 耗时大,险些超时,可以用BFS来做 */ #include <cstdio> #include <algorithm> #include &l…
题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN], t[MAXN]; int main(void) //Codeforces Round #301 (Div…
Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/482/problem/A Description Permutation p is an ordered set of integers p1,   p2,   ...,   pn, consisting of n distinct posi…
Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/C Description In the evening, after the contest Ilya was bored, and he really felt like ma…
题意与分析(CodeForces 540B) 题意大概是这样的,有一个考试鬼才能够随心所欲的控制自己的考试分数,但是有两个限制,第一总分不能超过一个数,不然就会被班里学生群嘲:第二分数的中位数(科目数保证为奇数)不能低于某个数,不然他妈就不让他打游戏.已知\(n\)门中\(k\)门成绩,求符合条件的其他科目的成绩.注意,不能考0分. 乍一看就是一个简单的贪心问题.但是细节相对较多. 抓住主要方向.先统计有多少门考不过中位数的,如果大于一半直接-1:然后按照这样的决策就可以了:小于一半的考1分,大…
[链接] 我是链接,点我呀:) [题意] 已知k门成绩. 总共有n门成绩. 让你构造剩下的n-k门成绩,使得这n门成绩的中位数>=y,并且这n门成绩的和要小于等于x. n为奇数 [题解] 首先判断k门成绩的和是不是小于等于x. 然后x-sum就是剩下的n-k个数字最多能填的和. 可以这样. 既然中位数要大于等于y; 那么转化为让(n+1)/2个数字都大于等于p; 则在剩下的n-k个位置凑足(n+1)/2个p就够了. 凑够了就都用1填就好. [代码] #include <bits/stdc++.…
A. Combination Lock time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there…