二分
阿晴0917
这个作者很懒,什么都没留下…
展开
-
2020牛客寒假算法基础集训营6 J-签到题 Yes不能大写 G括号序列 T组样例要清空栈 A配对k大 n-k+1小 原数组sort F 十字阵列 注意超时5e5次询问 D重排列 C汉诺塔LIS
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1e6+5;ll T,n,ans;double a,b,c,r[4];string s;int main(){ cin>>a>>b>>c; if(a+b>c &...原创 2020-02-26 19:15:19 · 205 阅读 · 0 评论 -
Codeforces1301B. Motarack's Birthday 三分 C. Ayoub's function字符串至少含1的子串数
https://codeforces.com/contest/1301/problem/B不存在的值-1表示 求使数组的最大差值最小 0<=ai<=1e9输出m表示差值 k表示-1位置的统一值最优k 减小或增大都会使差值超增大的趋势发展 是个关于最优k的凹函数注意:自己三分搞精度 l+5<=r 最后l,r之间大概5个左右的范围再判断哪一个位置maxx更小...原创 2020-02-20 11:37:09 · 202 阅读 · 0 评论 -
B-牛牛战队的比赛地 三分法 模板
https://blog.csdn.net/qq_33199236/article/details/53437875 三分极值 3分之#include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1e5+5;const double eps=1e-6;#define endl ...原创 2020-02-15 10:09:49 · 124 阅读 · 0 评论 -
Codeforces1295C vector存字母位置 二分nlogn B. Infinite Prefixes 字符串找规律模拟 D欧拉函数值应用 素因子分解
#include <bits/stdc++.h>using namespace std;#define endl '\n'#define IO ios::sync_with_stdio(false);cin.tie(0);#define pb push_backtypedef long long ll;typedef pair<int, int> pii;t...原创 2020-01-31 11:11:34 · 171 阅读 · 0 评论 -
G-卖萌型选手 二分
平方前缀和1e6左右时已经超过1e18n*(n+1)(2n+1)/6最大平方前缀不超过k 的位置对应的值#include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=2e6+5;const ll mod=1e9+7;const int INF=0x3f3f3f3f;#def...原创 2019-11-22 23:50:34 · 92 阅读 · 0 评论 -
Codeforces1148B 二分枚举lower_bound
https://codeforces.com/contest/1148/problem/BA->B 起飞时间n个B->C 起飞时间m个ta tb 航班乘坐这么多时间后到达至多删除k个航班 使最早到达时间最大化#include<bits/stdc++.h>using namespace std;const int maxn=1e6+5;typedef lon...原创 2019-11-01 22:32:43 · 125 阅读 · 0 评论 -
Codeforces1251D二分 B字符串奇偶性 A双指针 E优先队列维护贪心
https://codeforces.com/contest/1251/problem/D#include<bits/stdc++.h>using namespace std;const int maxn=1e6+5;typedef long long ll;#define rep(i,a,n) for(int i=a;i<=n;i++)ll t,n,s,m,vis[...原创 2019-10-28 21:10:42 · 122 阅读 · 0 评论 -
Codeforces1241C 二分 前缀和预处理logn*q D数组双指针
百分比(x+y)%最大的1241C不存在-1 n=2e5#include<bits/stdc++.h>using namespace std;typedef long long ll;#define IO ios::sync_with_stdio(false);cin.tie(0);const int maxn=1e6+5;ll n,m,q,r,ans;ll cnt;...原创 2019-10-10 20:49:44 · 304 阅读 · 0 评论 -
CometOJ国庆欢乐赛 C两排房子 二分 D1 二分贪心 E贪心特判
时间复杂度O(n*log2m)lower_bound 第一个大于等于upper_bound 第一个大于#include <bits/stdc++.h>using namespace std;const int Maxn = 2000005;int n, m, Xl[Maxn], Xr[Maxn], Yl[Maxn], Yr[Maxn];long long ans;in...原创 2019-10-02 13:41:37 · 121 阅读 · 0 评论 -
Codeforces1117C. Magic Ship 二分
https://codeforces.com/contest/1117/problem/C风先走风走的天数同时 船叠加走(0,0)->(4,6)mid=5天 1个T余2风UUUUU船RRRRU前缀和数组#include <bits/stdc++.h>using namespace std; #define rep(i,a,n) for (int i=a;i&...原创 2019-09-07 10:28:12 · 116 阅读 · 0 评论 -
Codeforces Round #521 (Div. 3)D. Cutting Out 二分
https://codeforces.com/contest/1077/problem/Dnlogn n=2e5#include <bits/stdc++.h>using namespace std;#define rep(i,a,n) for (int i=a;i<=n;i++)#define pb push_back#define mp make_pair#d...原创 2019-08-30 22:25:28 · 90 阅读 · 0 评论 -
Codeforces1208B 二分
https://codeforces.com/contest/1208/problem/Bn=2000 ai<=1e9 值访问次数最多2000n2logn=4e6*11=44e6=5e7#include <bits/stdc++.h>using namespace std;#define rep(i,a,n) for(int i=a;i<=n;i++)typed...原创 2019-08-30 22:21:16 · 205 阅读 · 0 评论 -
B.北境之都 (前缀+后缀)枚举 二分 1s
在遥远的北方有一个国家,这个国家有一个房地产商,他新盖的小区里有n座楼房他准备通过这个小区大赚一笔。但是国王胖赤耳颁布了一条奇怪的法令:一个小区中任意两个房子的高度差必须要小于等于M米。因此房地产商必须要调整房子的高度,使得任意两个房子的高度差均小于等于M米。每个房子只能改变一次高度,将一个房子的高度改变k米的花费是k^2万元,求房地产商最低要花费多少万元。输入描述输入第一行包含两个整数n,...原创 2019-03-26 19:35:13 · 221 阅读 · 0 评论 -
A.辛苦的志愿者 (队列+二分)2000ms
由于选手们实力过强,不断传来题目被AC的信息,发气球的志愿者小姐姐们实在忙不过来了。初始所有志愿者小姐姐均在等待区,每当有一道题目被AC,等待区就会产生一个气球。志愿者小姐姐发气球遵循以下规则:1.如果此时等待区有志愿者,则志愿者出发将此气球发给对应的队伍,并在t时间后返回等待区。2.如果此时等待区没有志愿者,则等待某一个志愿者回到等待区再出发发这只气球。3.当一个志愿者回到等待区时,等...原创 2019-03-26 19:34:55 · 144 阅读 · 0 评论 -
Codeforces1119D 排序二分 区间内贡献
https://codeforces.com/contest/1119/problem/D排序后求n-1个差值 差值为前一个能提供不同数的贡献对差值数组排序二分,小于查询的区间长度提供差值的贡献 否则提供区间长度的贡献ll n;int q;ll a[maxn],cha[maxn],pre[maxn];int main(){ IO; cin>>n; for(int i...原创 2019-04-08 23:51:39 · 208 阅读 · 0 评论 -
Codeforces 1119B 贪心二分
https://codeforces.com/contest/1119/problem/B不改变原数组的值,复制一份,要求1-k连续,则1-mid区间内判断子数组从大到小排序后,每两个相差不大,比较均匀 i+=2倒着的目的是前大后小 能装前一定能装后 尽量装更多的 累积高度和跳着累积高度和,如果<=h 可增加更多的瓶子,否则高度太多瓶子太多,减小瓶子数量const int maxn...原创 2019-04-09 00:07:09 · 197 阅读 · 0 评论 -
Codeforces 1166C A Tale of Two Lands
枚举x 每次符合条件y的个数 即为对数求和x<y<=2x upper_bound第一个大于2x 位置pos pos-1为<=2xi为x位置 i+1为>xpos-1-(i+1)+1#include<bits/stdc++.h>using namespace std;#define IO ios::sync_with_stdio(false)#d...原创 2019-05-23 21:26:58 · 246 阅读 · 0 评论 -
Codeforces 831D Office Keys 贪心枚举
暴力2e6复杂度先排序 左边人尽量拿左边钥匙 右边人尽量拿右边的 用n个人长度滑窗钥匙长度为k的区间 所有方案枚举比如2人 4把钥匙1-2 2-3 3-4 3种方案O(kn)=20001000=2e6ll a[maxn],b[maxn],vis[maxn];ll n,k,p,maxx=0;int main(){ cin>>n>>k...原创 2019-05-30 22:33:57 · 185 阅读 · 0 评论 -
Codeforces1183C 二分
假如cha=k-na=1-1e91e9=-1e18cha=-cha=1e18用llhttps://codeforces.com/contest/1183/problem/C#include<deque>using namespace std;#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)#def...原创 2019-07-23 20:17:13 · 239 阅读 · 0 评论 -
Codeforces1201 B C. Maximum Median 二分/数学
B每次找数组中的一对数-1最终能否使数组元素全为0#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<int,int> pii; //1e9typedef pair<ll,ll> pll;const int maxn=4e5+5;const i...原创 2019-08-05 15:11:02 · 194 阅读 · 0 评论 -
Codeforces1156 A画图 Bset 迭代器 C贪心二分
1 圆2 三角形 底与高相等3 正方形3 1 2 三点重合https://codeforces.com/contest/1156/problem/All n,k;ll a[maxn];ll res=0;int main(){ cin>>n; rep(i,1,n) cin>>a[i]; rep(i,1,n-1){ if(a[i]==1) { ...原创 2019-08-05 16:42:02 · 143 阅读 · 0 评论 -
Codforces1169C.Increasing by Modulo 二分
https://codeforces.com/contest/1169/problem/C#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<int,int> pii; //1e9typedef pair<ll,ll> pll;const int m...原创 2019-08-07 15:07:11 · 135 阅读 · 0 评论 -
Codeforces Round #540 (Div. 3)D2. Coffee and Coursework (Hard Version)(贪心 二分) 数据范围ll
https://codeforces.com/contest/1118/problem/D2n=2e5 ai 1e9 sum之和lltmp(先是1-mid之和) mid最大2e5 求和(1-mid) ll 2e14#include&lt;iostream&gt;#include&lt;cstdio&gt;#include&lt;algorithm&gt;#include&原创 2019-02-20 17:10:35 · 195 阅读 · 0 评论