题目:http://codeforces.com/problemset/problem/1042/A 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define mid ((l+r)>>1) using namespace std; ; int n,m,a[maxn],ans,mx; bool ck(int x) { ; ;i<…
D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
题目:http://codeforces.com/problemset/problem/1042/A #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int n,m,a[N],ans,mx; int main() { scanf("%d%d",&n,&m); ;i<=n;i…
无论再来多少次也不可能想到的写法. 二分一个最小的顶端值\(k\),大于设为\(1\)小于等于设为\(0\),可以证猜出来(你跟我说这可以?)如果存在两个连在一起的0/1那么它们会一直往上跑,还可以很容易就想到(容易?????)如果不存在相邻的情况(也就是交叉的那种)那么顶端答案一定是原先左右两边的值之一.. 不管了弃疗了.放代码. #include <bits/stdc++.h> using namespace std; const int N = 200010; int n, a[N &l…
A. Down the Hatch! time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Everybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all…
题目:http://codeforces.com/contest/949/problem/D 先二分一个答案,让两边都至少满足这个答案: 由于越靠中间的房间越容易满足(被检查的时间靠后),所以策略就是优先满足中间的房间,舍弃两边边缘的: 所以就由外到内推过来就可以了,用一个指针记录现在已经使用到的房间... 具体可以看这篇博客:https://www.cnblogs.com/Narh/p/9706060.html 代码如下: #include<iostream> #include<cst…
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2683 题意 原来有1个,每次可以任选数量成倍增长,问要操作多少次到n 思路 明显,先扩增到最大数位maxDigit,比如10,先扩增到8,然后再选择n - maxDigit扩增即可.因而结果为log2(n) 代码 #include <algorithm> #include…
There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can t…
二分答案水题. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 #define ll long long ll n,k,a[maxn],minn,maxx; #define llinf 10000000000000000LL #define F(i,j,k) for (l…
二分答案水题. (像我这么蒻的人都能十几分钟A掉) https://www.luogu.org/problemnew/show/P2920 开始时间一定在从0到min(t[i]-s[i])的一段区间上,因此我们可以愉快地二分答案. 在二分答案之前,我们贪心地把结束时间从小到大排一遍序,于是就可以二分了. 最后如果结果是负数,证明无解,不能完成任务.输出-1. Check函数里,模拟累加一下当前的时间加上最靠近ddl任务所花的时间,看能不能完成,进行判断. code #include<cstdio…