Find the hotel HDU - 3193 (ST表RMQ)】的更多相关文章

Summer again! Flynn is ready for another tour around. Since the tour would take three or more days, it is important to find a hotel that meets for a reasonable price and gets as near as possible! But there are so many of them! Flynn gets tired to loo…
题面:P2880 [USACO07JAN]平衡的阵容Balanced Lineup 题解: ST表板子 代码: #include<cstdio> #include<cstring> #include<iostream> #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b)) using namespace std; ,max_log=,maxlog=,inf=<<…
题意: 有n个旅馆,从这n个旅馆中找出若干个旅馆,使得这若干个旅馆满足这样的条件:不能从其它和剩下的旅馆中找到一个价格和距离都小于这个旅馆的旅馆... 解析: 按price 排序,若price相同, 则按距离排序 然后遍历每一个旅馆,在处理当前 旅馆时,二分在price小于当前旅馆price的旅馆中 找到最后一个price小于当前旅馆price的旅馆(因为可能price相同) 然后rmq求距离最小值就可 #include <iostream> #include <cstdio> #…
二维RMQ其实和一维差不太多,但是dp时要用四维 /* 二维rmq */ #include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; #define maxn 305 int val[maxn][maxn],n,m; ][]; void ST(){ ;i<=n;i++) ;j<=m;j++) dpmax[i][j][][]=v…
传送门:http://poj.org/problem?id=3368 Frequent values Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 23016   Accepted: 8060 Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that,…
类似hdu5289,但是二分更复杂.本题枚举左端点,右端点是一个区间,需要二分找到区间的左端点和右端点(自己手动模拟一次),然后区间长度就是结果增加的次数 另外结果开long long 保存 /** 二分法,枚举左端点,向右寻找第一个最大值不等于最小值的端点 */ #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> us…
  Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 36864   Accepted: 17263 Case Time Limit: 2000MS Description For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer J…
题目链接 题目 Description 给定一个非递减数列Ai,你只需要支持一个操作:求一段区间内出现最多的数字的出现次数. Input 第一行两个整数N,Q 接下来一行有N个整数,表示这个序列. 接下来Q行每行一个操作:A B,询问A到B之间出现最多的数字. 1<=N,Q<=100000.-100000<=Ai<=100000 Output 每组数据若干行,每行对应一个询问的答案. Sample Input 10 3 -1 -1 1 1 1 1 3 10 10 10 2 3 1…
Bob’s Race Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4123 Description Bob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N houses and N - 1 roads…
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3175    Accepted Submission(s): 1457 Problem Description Tom owns a company and he i…