题目传送门 /* 贪心水题 */ #include <cstdio> #include <algorithm> #include <iostream> #include <cmath> #include <cstring> #include <vector> #include <set> #include <map> #include <string> using namespace std; ;…
B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r and center in point (x, …
A. Amr and Music time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an…
B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r and center in point (x, …
题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再看自己的代码发现有清晰的思维是多重要 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include…
题目传送门 /* 贪心:首先要注意,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…
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; in…
题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; int a[MAXN]; int main(vo…
题目传送门 /* 题意:找到一个字符串p,使得它和s,t的不同的总个数相同 贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> using namespace std; ; const int INF = 0x3f3f3f3f; int p[MAXN…
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN]; int main(void) //Codeforce…