Interesting drink Problem Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that th…
题目链接: http://codeforces.com/problemset/problem/706/B 题目大意: n (1 ≤ n ≤ 100 000)个商店卖一个东西,每个商店的价格Ai,你有m(1≤m≤100 000)天,每天有Cj的钱,问每天可以负的起的商店数. 题目思路: [二分] 排个序,二分. // //by coolxxx // #include<iostream> #include<algorithm> #include<string> #inclu…
https://codeforces.com/problemset/problem/706/B 因为没有看见 $x_i$ 的上限是 $10^5$ ,就用了二分去做,实际上这道题因为可乐的价格上限是 $10^6$ ,可以用复杂度为 $O(max(x_i))$ 的dp去做. 也就是说,当这道题的可乐数量上升,二分就容易超时,而可乐的价格上升则dp容易爆内存且超时.各有所长 #include<bits/stdc++.h> using namespace std; #define ll long lo…
题意:给定 n 个数,然后有 m 个询问,每个询问一个数,问你小于等于这个数的数有多少个. 析:其实很简单么,先排序,然后十分查找,so easy. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <…
排序,二分. 将$x$数组从小到大排序,每次询问的时候只要二分一下位置就可以了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include&l…
题目链接: B. Interesting drink 题意: 给出第i个商店的价钱为x[i],现在询问mi能在多少个地方买酒; 思路: sort后再二分; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <bits/stdc++.…
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bough…
题目链接:Codeforces 482B Interesting Array 题目大意:给定一个长度为N的数组,如今有M个限制,每一个限制有l,r,q,表示从a[l]~a[r]取且后的数一定为q,问是 否有满足的数列. 解题思路:线段树维护.每条限制等于是对l~r之间的数或上q(取且的性质,对应二进制位一定为1).那么处理全然部的 限制.在进行查询.查询相应每一个l~r之间的数取且是否还等于q.所以用线段树维护取且和.改动为或操作. #include <cstdio> #include <…
题目:codeforces 482B. Interesting Array 题意:给你一个值n和m中操作,每种操作就是三个数 l ,r,val. 就是区间l---r上的与的值为val,最后问你原来的数组是多少?假设不存在输出no 分析:分析发现要满足全部的区间,而一个点上假如有多个区间的话,这个点的值就是全部区间或的值.由于仅仅有这样才干满足全部区间的.把全部位上的1都保存下来了.那么能够发现用线段树来维护,可是那么怎么推断满不满足条件呢?能够也用线段树,更新了之后在整个维护一遍看看满不满足题意…
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> using namespace std; const int maxn = 1000010; int value[maxn]; int money[maxn]; int n,m; int main() { scanf(&qu…