bzoj5085: 最大 暴力 二分】的更多相关文章

Code: #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<string> using namespace std; void setIO(string a){ freopen((a+".in").c_str(),"r",stdin); } const int maxn=1000+3; in…
2017-08-26 11:38:42 writer:pprp 已经是第二次写这个题了,但是还是出了很多毛病 先给出AC代码: 解题思路: 之前在培训的时候只是笼统的讲了讲怎么做,进行二分对其中一边进行暴力枚举,对另一边用lower_bound查找算出的相反数 现在给出详细一点的思路: 答案可能在左边枚举的部分,也可能在右边枚举的部分,也可能在两边加起来的和中 所以从这三个方面不能少考虑: 还有用到了map所以算出来的key是唯一的,所以当算出来两个key相等的时候,应该采用value也就是cn…
题目描述 给你一个n×m的矩形,要你找一个子矩形,价值为左上角左下角右上角右下角这四个数的最小值,要你最大化矩形的价值. 输入 第一行两个数n,m,接下来n行每行m个数,用来描述矩形 n, m ≤ 1000 输出 输出一个数表示答案 样例输入 2 2 1 2 3 4 样例输出 1 题解 二分+暴力 首先题目问的是最小值最大,显然二分答案,问题转化为判断是否存在一个子矩形,满足四个角的权值大于等于mid. 考虑暴力怎么做:枚举所有与x轴平行的线段(即同行的线段),判断是否有两个线段的端点横坐标相同…
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…
Subsequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10875   Accepted: 4493 Description A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) ar…
一元三次方程求解 描述 有形如:ax^3+bx^2+cx+d=0 这样的一个一元三次方程.给出该方程中各项的系数(a,b,c,d 均为实数),并约定该方程存在三个不同实根(根的范围在-100至100之间),且根与根之差的绝对值>=1.要求由小到大依次在同一行输出这三个实根(根与根之间留有空格),并精确到小数点后2位. 格式 输入格式 输入该方程中各项的系数(a,b,c,d 均为实数), 输出格式 由小到大依次在同一行输出这三个实根(根与根之间留有空格),并精确到小数点后2位. 样例1 样例输入1…
为甚么16年Qingdao Online 都是暴力题emm///... 先暴力预处理 然后lower _bound二分 #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <cctype> #include <set> #include <vector> #incl…
LINK 题意:给出n个点,每个点有个权值,可以和任意另外一点构成线段,值为权值积.现问过原点的直线中交所有线段的权值和的最大值,注意直线必不经过点. 思路:直线可以将点集分为两侧,此时的权值为两侧点的乘积.而且由于是过原点的直线,所以不用暴力枚举两个点了...直接极角排序,这里我原先的极角排序有点小问题,最后还是找的别人的,以(0,x)为最小极角的. 然后前缀和权值以便分组求积. 枚举点,与原点相连作直线,然后以枚举点的对称点,二分找到最大的在它顺时针侧的点,然后注意要注意枚举点是否包含的两种…
B. Lorry 题目连接: http://www.codeforces.com/contest/3/problem/B Description A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that a…
D. Image Preview 题目连接: http://www.codeforces.com/contest/651/problem/D Description Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over…
E. Simple Skewness 题目连接: http://www.codeforces.com/contest/626/problem/E Description Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of n (not necessarily distinct) integers. Fi…
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya's telephone contains n photos. Photo number 1 is currently opened on…
http://hihocoder.com/problemset/problem/1288 这题是这次微软笔试的第一题,关键的是s的上限是min(w, h),这样s的范围只有到1000,这样就可以直接暴力了,当然用二分也行,不过暴力写起来更快一点. 代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #inc…
给出N个整数,你来判断一下是否能够选出4个数,他们的和为0,可以则输出"Yes",否则输出"No". Input 第1行,1个数N,N为数组的长度(4 <= N <= 1000) 第2 - N + 1行:A[i](-10^9 <= A[i] <= 10^9) Output 如果可以选出4个数,使得他们的和为0,则输出"Yes",否则输出"No". Input示例 5 -1 1 -5 2 4 Output…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2141 题目大意: 给ABC三个数组,给一个X,求是否存在Ai+Bj+Ck = X 思路: 等式转化成Ai+Bj = X-Ck 这样预处理出Ai+Bj的所有数字,然后循环k,二分查找X-Ck是否存在. 首先用set超内存,然后用数组结果一直WA,二分的时候少了个"=" 这真是醉了. 果然深夜不适合刷题 #include<iostream> #include<vector&…
题目链接:http://poj.org/problem?id=2785 大意是输入一个n行四列的矩阵,每一列取一个数,就是四个数,求有多少种着四个数相加和为0的情况 首先脑海里想到的第一思维必然是一个个枚举,用四个for循环,那时间复杂度变成了On4,n的最大值是4000. 肯定会超时.那么,为了简化时间,首先我们可以开两个至少4000*4000的数组分别把第一列与第二列的和的情况 ,第三列与第四列的和的情况存起来.这样就只用考虑两个数组的情况. 然后把两个数组排序,一个数组从头部开始同时另一个…
给出一个长度为N的无序数组,数组中的元素为整数,有正有负包括0,并互不相等.从中找出所有和 = 0的3个数的组合.如果没有这样的组合,输出No Solution.如果有多个,按照3个数中最小的数从小到大排序,如果最小的数相等则按照第二小的数排序.   Input 第1行,1个数N,N为数组的长度(0 <= N <= 1000) 第2 - N + 1行:A[i](-10^9 <= A[i] <= 10^9) Output 如果没有符合条件的组合,输出No Solution. 如果有多…
B. Skills 题目连接: http://www.codeforces.com/contest/613/problem/B Description Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly…
F. Multicolored Markers 题目大意: 给你 a个红块 b个蓝块 拼成一个实心矩形,并且要求红块或者蓝块自成一个矩形,问形成的这个矩形最小的周长是多少. #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <stack> #include <bitset> #include <vector&g…
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each succe…
传送门:点我 A plane is flying at a constant height of hh meters above the ground surface. Let's consider that it is flying from the point (−10^9,h)(−10^9,h) to the point (10^9,h)(10^9,h) parallel with Ox axis. A glider is inside the plane, ready to start…
GCD/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Give you a sequence of N(N≤100,000) integers : a1,...,an(0<ai≤1000,000,000). There are Q(Q≤100,000) queries. For each query l,r you have to calculate gcd(al,,al+1,...,ar) a…
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! As…
C. Vasya and String 题目连接: http://www.codeforces.com/contest/676/problem/C Description High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as th…
C. Block Towers 题目连接: http://www.codeforces.com/contest/626/problem/C Description Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces…
考虑到答案满足可二分性,段内可以贪心,所以暴力二分即可 注意-1 详见代码(我这题都能写WA) #include <bits/stdc++.h> using namespace std; int l,n,k,a[100005]; int main() { ios::sync_with_stdio(false); cin>>l>>n>>k; for(int i=1;i<=n;i++) cin>>a[i]; int L=0,R=l+1; whi…
Description 神犇SJY虐完HEOI之后给傻×LYD出了一题:SHY是T国的公主,平时的一大爱好是作诗.由于时间紧迫,SHY作完诗之后还要虐OI,于是SHY找来一篇长度为N的文章,阅读M次,每次只阅读其中连续的一段[l,r],从这一段中选出一些汉字构成诗.因为SHY喜欢对偶,所以SHY规定最后选出的每个汉字都必须在[l,r]里出现了正偶数次.而且SHY认为选出的汉字的种类数(两个一样的汉字称为同一种)越多越好(为了拿到更多的素材!).于是SHY请LYD安排选法.LYD这种傻×当然不会了…
#include<cstdio> #include<iostream> #define N 201 #define M 500008 using namespace std; *M],rs[*M],root[M],ans,sum[*M],sum1[*M],shu,num[][N][N],num1[][N][N]; void jia(int l,int r,int x,int &y,int v) { y=++cnt; sum[y]=sum[x]+v; sum1[y]=sum1…
2016 round A A. Googol String small && large LL a[]; int dfs(LL pos, int id, bool f) { || pos==a[id-]+) :; ]) , id-, f^); else , f); } int main() { freopen("A-small-practice.in", "r", stdin); freopen("A.out", "w&…