CodeForces 706B Interesting drink】的更多相关文章

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都保存下来了.那么能够发现用线段树来维护,可是那么怎么推断满不满足条件呢?能够也用线段树,更新了之后在整个维护一遍看看满不满足题意…
链接 [http://codeforces.com/group/1EzrFFyOc0/contest/706/problem/B] 题意 给你n个数,q次查询,每次输入一个m,问n个数中有多少个数小于等于m 思路 先排序,再用upper_bound找,该函数返回第一个大于m的下标. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ios::sync_with_stdio(fals…
题目链接 Interesting Array 区间更新.然后对于每一个约数重新求一遍区间的&值,不符合就跳出. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define lson i << 1, L, mid #define rson i << 1 | 1, mid + 1, R ; struct node…
题目描述: D. Interesting Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of t…
#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…
题意:构造一个长度为n的序列,使其满足m个形式如下如下约束:a[l]&a[l+1]&a[l+2]&....&a[r]=q 从Dalao的博客上看到这题,决定去水水.做法比较显然,就是做一些区间or之后判断一下之前的条件是否满足.用线段树维护即可. 不出意外,我的线段树又调爆了,因为我把<<打成了>>.... #include<bits/stdc++.h> using namespace std; #define MAXN 1000000+…
题目大意: 两个好朋友再将一堆物品分堆,每次都将一堆物品分成数量连续的至少两个堆,直到一个人不能分堆为输 第一次做博弈问题,看了百度文库的http://wenku.baidu.com/link?url=C6qxEhqBEJJFDPC2nSW8kaOer2s_WyOxAhUi0QzF_-B38Gw7KqbbjFvuiaLUvuoGYtliZE_JAH_PO1VPpOT1Vo5OvbyPzBR3Q5IlmWYIHuy 感觉讲的还是蛮好的 这里因为每次至少要分两个堆 所以初始sg[0] = sg[1]…
题意: 你有一个长度为n的序列a(这个序列只能使用[1,n]区间内的数字,每个数字只能使用一次),通过a序列可以构造出来三个相同长度的序列f.g.h For each 1≤i≤n, fi=max{a1,a2,-,ai}; For each 1≤i≤n, gi=min{a1,a2,-,ai}; For each 1≤i≤n, hi=fi−gi. 问你,如果给你h序列,你要找出来满足h序列的a序列的个数.答案很大你可以取模于1e9+7 题解: 一. 首先先特判掉几种情况 1.如果h数组里面出现hi>…
1.CF 706B  Interesting drink 2.链接:http://codeforces.com/problemset/problem/706/B 3.总结:二分 题意:给出n个数,再给出q个mi,每次求n个数里有多少个数<=mi #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #include&l…
Codeforces Round 367 Div. 2 点击打开链接 A. Beru-taxi (1s, 256MB) 题目大意:在平面上 \(n\) 个点 \((x_i,y_i)\) 上有出租车,每辆出租车的行驶速度为 \(v_i\),求所有出租车到点 \((a,b)\) 的时间中的最短时间. 数据范围:\(-100 \leq a,b,x_i,y_i \leq 100\),\(v_i \leq 100\),\(n \leq 1000\) 简要题解:依次求出所有的时间,取最小值即可. 时空复杂度…
A题 Beru-taxi 随便搞搞.. #include <cstdio> #include <cmath> using namespace std; int a,b,n; struct _ { int x,y,v; }p[]; double dis2(_ A) { return (a - A.x) * (a - A.x) + (b - A.y) * (b - A.y); } int main() { scanf("%d%d%d", &a, &b…
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> #include<math.h> #include<vector> using namespace…
A. Beru-taxi time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as…
A. Beru-taxi time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as…
吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string>…
又是两个黑科技一般的存在. 首先我们来介绍一下这两个函数: ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val) 返回一个非递减序列[first, last)中的第一个大于等于值val的位置. ForwardIter upper_bound(ForwardIter first, ForwardIter last, const _Tp& val) 返回一个非递减序列[first, last)中第…
原文地址:http://blog.csdn.net/zearot/article/details/48299459(如有侵权,请联系博主,立即删除.) 线段树详解    By 岩之痕 目录: 一:综述     二:原理    三:递归实现    四:非递归原理      五:非递归实现 六:线段树解题模型    七:扫描线   八:可持久化 (主席树)     九:练习题 一:综述 假设有编号从1到n的n个点,每个点都存了一些信息,用[L,R]表示下标从L到R的这些点. 线段树的用处就是,对编号…
题目链接: http://codeforces.com/contest/703/problem/D D. Mishka and Interesting sum time limit per test 3.5 secondsmemory limit per test 256 megabytes 问题描述 Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to prese…
Codeforces 1109D. Sasha and Interesting Fact from Graph Theory 解题思路: 这题我根本不会做,是周指导带飞我. 首先对于当前已经有 \(m\) 个联通块的有标号生成树的数量是 \[ n^{m-2}\prod_{i=1}^msize_i \] 其中 \(size_i\) 是第 \(i\) 个联通块的大小. 原理就是考虑 \(prufer\) 编码,先把每个联通块看成一个点,那么序列中每出现一个第 \(i\) 联通块缩成的点,能连的边的数…
E. Interesting Graph and Apples 题目连接: http://www.codeforces.com/contest/9/problem/E Description Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph a…
链接 Codeforces 703D Mishka and Interesting sum 题意 求区间内数字出现次数为偶数的数的异或和 思路 区间内直接异或的话得到的是出现次数为奇数的异或和,要得到偶数的需要把区间内出现过的数字不重复的再异或一遍.离线按右端点排序,每次处理一个区间时,如果该数字出现过,则在树状数组中把这个数删去,再重新再该位置加到树状数组中. 代码…
题目链接:http://codeforces.com/contest/703/problem/D 思路:看了神犇的代码写的... 偶数个相同的数异或结果为0,所以区间ans[l , r]=区间[l , r]每个数相异或^区间[l , r]出现过的数相异或.如数组1,2,1,3,3,2,3,则ans[1 , 7]=(1^2^1^3^3^2^3)^(1^2^3) 前半部分可以处理出前缀异或,后半部分先对询问按r进行排序,处理过程中相同的数只保留最后一个. #include<bits/stdc++.h…