类似hdu5289,但是二分更复杂。本题枚举左端点,右端点是一个区间,需要二分找到区间的左端点和右端点(自己手动模拟一次),然后区间长度就是结果增加的次数 另外结果开long long 保存 ...
分类:
其他好文 时间:
2018-11-26 23:15:22
阅读次数:
192
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5289 题意:给定长度为n的序列a和一个整数K,找出最大值和最小值的差值小于K的区间。输出满足条件的区间的个数。 分析:枚举a[i],以a[i]为起点,然后二分找终点(大区间满足条件的话小区间肯定也满足),依 ...
分类:
编程语言 时间:
2017-04-25 10:04:10
阅读次数:
133
RMQ预处理最大值,最小值,然后对于每一点,二分可能满足的区间长度,长度-1就是该店开始的区间满足的个数。#include#include#include#define maxn 100010#define LL __int64int dp1[maxn][20],n,a[maxn],dp2[maxn...
分类:
其他好文 时间:
2015-10-08 23:14:33
阅读次数:
218
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2555 Accepted Submission(s): 1200
Problem Description
Tom owns a company and he i...
分类:
其他好文 时间:
2015-08-17 12:01:14
阅读次数:
107
解题报告 之 HDU5289 Assignment
Description
Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task to some staffs who were in the same g...
分类:
其他好文 时间:
2015-08-13 15:54:37
阅读次数:
122
这题说的是给了 n个数 然后让你计算出所有区间中那些数的最大值减最小值小于k这样的区间有多少个/* 这样我们给我们在处理过程中的区间做一些处理 我们在处理即将进来的数的时候我们并不知道他是不是我们区间的最小或者最大值 但是我们可以将他们处理一下 用两个队列 一个队列放的逐渐减小的数列 一个放...
分类:
其他好文 时间:
2015-07-25 13:43:46
阅读次数:
138
题目大意:给出一个数列,问其中存在多少连续子序列,子序列的最大值-最小值#include
#include
#include
#include
#include
using namespace std;int maxsum[100000][30];
int minsum[100000][30];int...
分类:
其他好文 时间:
2015-07-24 22:37:54
阅读次数:
162
题意:给出一个数列,问其中存在多少连续子区间,其中子区间的(最大值-最小值)
思路:设dp[i]为从区间1到i满足题意条件的解,最终解即为dp[n];
此外 假设对于arr[i] 往左遍历 一直到arr[r] 此时从区间r到区间i满足(最大值-最小值),再往左一位即越界 或者 不满足条件,此时有 dp[i]
= dp[i-1]
+ i - r
+ 1;
因为数据量大 往左遍历时 可能...
分类:
其他好文 时间:
2015-07-24 18:33:44
阅读次数:
96
Assignment
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 503 Accepted Submission(s): 256
Problem Description
Tom owns a compan...
分类:
其他好文 时间:
2015-07-22 09:24:35
阅读次数:
132
http://acm.hdu.edu.cn/showproblem.php?pid=5289
Problem Description
Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has...
分类:
其他好文 时间:
2015-07-21 22:18:32
阅读次数:
185