Consecutive Subsequence CodeForces - 977F 题目大意:输出一序列中的最大的连续数列的长度和与其对应的下标(连续是指 7 8 9这样的数列) 解题思路: 状态:把dp[i]定义为数列末尾为 i 的最大连续数列的长度值 状态转移方程:dp[i] = dp[i-1] + 1 再由最大连续数列最后一个值从后往前倒推出前面的所有值,到不是连续时停止 代码: #include<bits/stdc++.h> using namespace std; + ; int d…
You are given an integer array of length nn. You have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to […
题目链接:http://codeforces.com/problemset/problem/977/F 题意: 给定一个长度为 $n$ 的整数序列 $a[1 \sim n]$,要求你找到一个它最长的一个子序列,该子序列满足单调连续递增. 子序列可以不连续,单调连续递增即例如 $[4,5,6,7]$ 或者 $[6,7,8,9,10]$ 这样的. 题解: $f[i]$ 表示以 $a[i]$ 为结尾的最长连续递增子序列,那么要转移就需要找到 $[1,i-1]$ 这个区间内,某个满足 $a[j] = a…
B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negativ…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3357 题意: 给你n个数a[i],让你找出一个最长的是等差数列的子序列. 题解: 表示状态: dp[i][a[j]] = max len 表示当前选了a[i],上一个数是a[j]时,最长的等差数列长度. 找出答案: max dp[i][a[j]] 如何转移: map<int,int> dp[MAX_N]; dp[i][a[j]] = max dp[a[j]][2*a[j] - a[i]…
The time of a day Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 1297    Accepted Submission(s): 594 Problem Description There are no days and nights on byte island, so the residents here can h…
D - Yet Another Problem On a Subsequence CodeForces - 1000D The sequence of integers a1,a2,-,aka1,a2,-,ak is called a good array if a1=k−1a1=k−1 and a1>0a1>0. For example, the sequences [3,−1,44,0],[1,−99][3,−1,44,0],[1,−99] are good arrays, and the…
D - The Bakery CodeForces - 834D 这个题目好难啊,我理解了好久,都没有怎么理解好, 这种线段树优化dp,感觉还是很难的. 直接说思路吧,说不清楚就看代码吧. 这个题目转移方程还是很好写的, dp[i][j]表示前面 i 个蛋糕 分成了 j 个数字的最大价值. dp[i][j]=max(dp[k][j-1]+val[k+1~i]) 显而易见的是,这个肯定不可以直接暴力求,所以就要用到线段树优化. 线段树怎么优化呢, 先看这个问题,给你一个点 x ,问你以这个点为右端…
D. The Bakery time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input output standard output Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven whic…
题目链接   Educational Codeforces Round 39 Problem G 题意  给定一个序列,求把他变成Almost Increasing Array需要改变的最小元素个数. Almost Increasing Array为删掉至多一个元素之后可以成为严格递增子序列的数列. 这类题有个常见的套路,就是对每个元素减去下标之后求LIS. 这道题中可以删去一个元素,我们可以枚举哪个元素是被删掉的, 那么他之前的元素求LIS的时候真正的值为$a_{i} - i$,他之后的元素求…