这道题目的题意就是使用题目中所给的Gate 函数,模拟出输入的结果 当然我们分析的时候可以倒着来,就是拿输入去减 每次Gate 函数都会有一个有效范围 这道题目求的就是,找出一种模拟方法,使得最小的有效范围最大化. 是一道[贪心]题 参考了https://github.com/boleynsu/acmicpc-codes 的做法 b 数组中存放是 Sequence 的下标 这是一个O(n)的算法 if (a[i-1]<a[i]){ int k=a[i]-a[i-1]; while (k--) b…
HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Description WANGPENG is a freshman. He is requested to have a physical examination when entering the university. Now WANGPENG arrives at the hospital. Er-.. Th…
HDU 3397 Sequence operation 题目链接 题意:给定一个01序列,有5种操作 0 a b [a.b]区间置为0 1 a b [a,b]区间置为1 2 a b [a,b]区间0变成1,1变成0 3 a b 查询[a,b]区间1的个数 4 a b 查询[a,b]区间连续1最长的长度 思路:线段树线段合并.须要两个延迟标记一个置为01,一个翻转,然后因为4操作,须要记录左边最长0.1.右边最长0.1,区间最长0.1,然后区间合并去搞就可以 代码: #include <cstdi…
Least Cost Bracket Sequence(贪心) Describe This is yet another problem on regular bracket sequences. A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequenc…
Divide the Sequence 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5783 Description Alice has a sequence A, She wants to split A into as much as possible continuous subsequences, satisfying that for each subsequence, every its prefix sum is not smal…
Description Steph is extremely obsessed with "sequence problems" that are usually seen on magazines: Given the sequence 11, 23, 30, 35, what is the next number? Steph always finds them too easy for such a genius like himself until one day Klay c…
Description There is a special number sequence which has n+1 integers. For each number in sequence, we have two rules: ● a i ∈ [0,n] ● a i ≠ a j( i ≠ j ) For sequence a and sequence b, the integrating degree t is defined as follows(“�” denotes exclus…
Balanced Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6311    Accepted Submission(s): 1648 Problem Description Chiaki has n strings s1,s2,…,sn consisting of '(' and ')'. A string of…
题意:题意一开始不是很明白...就是他给你n个串,让你重新排列组合这n个串(每个串内部顺序不变),使得匹配的括号长度最大.注意,题目要求not necessary continuous,括号匹配不需要连续. 思路:我们先把每个串里面能组合的全部抵消,比如)((()抵消完为)((.我们能知道,这样操作完只会有4种情况留下:))))),((((((((,)((((((,))))))))(.然后排序,排序的时候为了后面匹配能最大化利用所有括号,我们需要把左括号尽可能多的放在左边,右括号尽可能多的放在右…
Ball 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes numbered 1,2,...,n. Each box can contain at most one ball. You are given the initial configuration of the balls. For 1≤i≤n, if the i-th box is empty the…