1.区间是一段的,不是断开的哟 2.代码是看着标程写的 3.枚举左端点,二分右端点流程: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> #include<cstdio> #include<cstring> #include<cmath&…
Assignment 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5289 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…
HDU 5289 - Assignment http://acm.hdu.edu.cn/showproblem.php?pid=5289 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 t…
Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 902    Accepted Submission(s): 441 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered fro…
B. Powers of Two   You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i. e. some integer xexists so that ai + aj = 2x). Input The first line contains the single positive integer n …
一个数组求其最长递增子序列(LIS) 例如数组{3, 1, 4, 2, 3, 9, 4, 6}的LIS是{1, 2, 3, 4, 6},长度为5,假设数组长度为N,求数组的LIS的长度, 需要一个额外的数组 LIS 来记录 长度从1 到 n 慢慢变长求解的过程中 对应长度的 最长递增子序列的最小的末尾元素 解决方法 长度为1时 {3}: 将3放入LIS中,表示长度为1的时候,{3}数组的最长递增子序列的最小微元素 LIS:{3} 只有一个元素,所以 最长递增子序列就是 {3},最长递增子序列的最…
题意:求一段长度为n的序列里有多少个子区间内的最大值减最小值小于k. 解法:RMQ+尺取法或单调队列.RMQ可以用st或者线段树,尺取法以前貌似YY出来过……只是不知道是这个东西…… 设两个标记l和r,对于区间[l, r]如果满足题中条件则ans+=(r - l + 1),然后r右移一位,直到不符合条件,将l左移,直到符合条件. 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include&l…
题意:给T足数据,然后每组一个n和k,表示n个数,k表示最大同意的能力差,接下来n个数表示n个人的能力,求能力差在k之内的区间有几个 分析:维护一个区间的最大值和最小值,使得他们的差小于k,于是採用单调队列 普通单调队列做法: #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; const int maxn = 1e6+5; i…
[题目链接]click here~~ [题目大意]: 给出一个数列,问当中存在多少连续子序列,子序列的最大值-最小值<k [思路]:枚举数列左端点.然后二分枚举右端点,用ST算法求区间最值.(或用单调队列的思路) 代码: #include <bits/stdc++.h> using namespace std; const int N=1e5+10; typedef long long LL; #define Max(a,b) a>b?a:b #define Min(a,b) a&…
Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3813    Accepted Submission(s): 1771 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered…