摘要: 题目传递门 本题是一道二分答案的板子题,有一点点贪心。 总结: 1、$l$与$r$的确定,我喜欢使用数组排序来获取最终的最大值,即$r$;而$l$不一定是数组的最小值,这个和题意有关,也可能是$0$。 2、即然是二分答案的模板题,那板子是必须的,另一个重要的问题就是$check$函数了,它需要检查什 阅读全文
posted @ 2021-07-22 17:10 糖豆爸爸 阅读(540) 评论(0) 推荐(2)
摘要: 题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int a[N]; int n; LL m; bool check(int x) { LL sum = 阅读全文
posted @ 2021-07-22 11:16 糖豆爸爸 阅读(102) 评论(0) 推荐(0)
摘要: 题目传送门 一、二分法解法 #include <bits/stdc++.h> using namespace std; const int N = 200010; int a[N]; int c; typedef long long LL; LL cnt; int main() { int n; c 阅读全文
posted @ 2021-07-22 09:50 糖豆爸爸 阅读(93) 评论(0) 推荐(0)
摘要: 题目传送门 #include <bits/stdc++.h> using namespace std; int n, m, k; const int N = 1e6 + 10; int a[N]; bool check(int mid) { return a[mid] >= k; } int mai 阅读全文
posted @ 2021-07-22 08:50 糖豆爸爸 阅读(87) 评论(0) 推荐(0)
Live2D