题目传送门 /* 题意:一个汉堡制作由字符串得出,自己有一些原材料,还有钱可以去商店购买原材料,问最多能做几个汉堡 二分:二分汉堡个数,判断此时所花费的钱是否在规定以内 */ #include <cstdio> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; char ham[MAXN]; ll n…
C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that…
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http://blog.csdn.net/libin56842/article/details/45082747 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> us…
500pt, 题目链接:http://codeforces.com/problemset/problem/371/A 分析:k-periodic说明每一段长度为k,整个数组被分成这样长度为k的片段,要使得修改最少,求出k长度的片段中每个位置出现次数最多的数就行. 代码: #include <vector> #include <list> #include <map> #include <set> #include <deque> #include…
C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that…
D. Vessels time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered fr…
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The be…
A,B大水题,不过B题逗比了题意没理解清楚,讲的太不清楚了感觉= =还是英语弱,白白错了两发. C: 二分答案判断是否可行,也逗比了下...二分的上界开太大导致爆long long了...   D: 看完题想都不想就用线段树搞起了,虽然我知道并查集很简单..不过没用并查集写过区间处理的问题就不用多想了.. 刚开始时,所有的船都是空的,也就是说可放的水量是船的容量,然后对于第一个操作,意思就是从第x个数开始减小直到减小了p或者后面都变成0了.这里我就二分查找下最右边的会减小的数R,然后把x~R-1…
Codeforces Round #404 (Div. 2) 题意:对于 n and m (1 ≤ n, m ≤ 10^18)  找到 1) [n<= m] cout<<n; 2) [n>m]最小的 k => (k -m) * (k-m+1) >= (n-m)*2 成立 思路:二分搜索 #include <bits/stdc++.h> #include <map> using namespace std; #define LL long long…
Codeforces Round #725 (Div. 3) 20210704.网址:https://codeforces.com/contest/1538. 感觉这个比上一个要难. A 有一个n个数的数组,我们每次只能拿走最左边/最右边的数.想把最大/最小的数都拿走,最少拿几次. 读入的时候就记录下来最大最小的位置,设左边位置为x,右边位置为y.要不[从左边拿直到拿走y],要不[从右边拿直到拿走x],要不[从左边拿直到x+从右边拿直到y],取个min就可以了. B 大水题,首先判能不能整除(平…