摘要: 题目链接:http://codeforces.com/contest/1157/problem/E 题意:调整b数组顺序,使得c数组最小化(c[i] = a[i] + b[i]) % n,因为这里a[i],b[i] < n,所以我们对每个a[i]在b数组中查找一个>=n - a[i]的值即可满足c数 阅读全文
posted @ 2019-06-02 13:17 html_11 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://codeforces.com/contest/1157/problem/C2 当左右两边数字相同时,需要判断一下取哪边能得到更长的递增序列 #include <iostream> #include <cstring> #include <algorithm> #include 阅读全文
posted @ 2019-06-01 16:17 html_11 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6026 拓扑排序判断环是否存在,DFS搜1~n大于/小于i的元素数量 #include <iostream> #include <cstdio> #include <al 阅读全文
posted @ 2019-06-01 11:24 html_11 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4110 两个字符串不相同时的情况比较简单: 只需要分别找到两个字符串左右两边第一个不相同字符的下标,然后开始对称匹配两个字符串,判断出是否有可能翻转一次使得s1->s 阅读全文
posted @ 2019-06-01 11:22 html_11 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://codeforces.com/contest/1165/problem/F2 题意:n种物品需要购买,每种物品需要购买a[i]件,每件物品价格为2bourle,有m次优惠活动(di,ti):第di天物品ti价值优惠为1bourle 每天可以得到1bourle,求买完所有物品的 阅读全文
posted @ 2019-06-01 11:14 html_11 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://codeforces.com/contest/1165/problem/E 题意: 改变数组B的顺序,使得最小 我们可以把 a[i] * (i + 1)*(n - i) 可以处理成定值,然后从大到小排序与从小到大排序的b数组相乘即为答案 #include <iostream> 阅读全文
posted @ 2019-05-31 11:58 html_11 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 线段树 题目链接 普通的线段树,跑了2000ms... #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <map> #include <set> #include <vect 阅读全文
posted @ 2019-05-29 23:08 html_11 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 二维前缀和 差分 题目链接 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <map> #include <set> #include <vector> #include < 阅读全文
posted @ 2019-05-29 00:14 html_11 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 树状数组 离散化 莫队 题目链接 求[L,R]内有多少对(i, j)满足|a[i] - a[j]| <= K,我们转换为求[a[i] - k - 1, a[i] + k]的个数 离散化处理a[i], a[i] - k, a[i] + k的下标(二分处理) 然后莫队查询,用树状数组维护这些数,实现区间 阅读全文
posted @ 2019-05-26 23:21 html_11 阅读(358) 评论(0) 推荐(0) 编辑
摘要: 离线莫队 题目链接 [L,R]区间内: 设每种袜子的数量分别为: 则答案为: 化简即为: 所以我们求:即可 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <map> #in 阅读全文
posted @ 2019-05-26 18:53 html_11 阅读(126) 评论(0) 推荐(0) 编辑