【codeforces 797E】Array Queries】的更多相关文章

[题目链接]:http://codeforces.com/problemset/problem/797/E [题意] 给你一个n个元素的数组; 每个元素都在1..n之间; 然后给你q个询问; 每个询问由p和k构成; 会对p进行 p=p+a[p]+k操作若干次; 你要输出p第一次大于n之后操作了多少次; [题解] 部分DP; 这里对于k>400的询问; 我们直接暴力求解; 因为这时暴力所花费的时间已经可以接受了; 而对于剩余的k<=400的询问; 我们写一个记忆化搜索来求解; 很棒的思路吧 [N…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举最大值和最小值在什么地方. 显然,只要包含最小值的区间,都让他减少. 因为就算那个区间包含最大值,也无所谓,因为不会让答案变小. 但是那些不包含最大值的区间却能让差值变大. 所以没有问题. [代码] #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 300; int n,m; int a[N+10],segl[N+10],…
题 You are given array ai of length n. You may consecutively apply two operations to this array: remove some subsegment (continuous subsequence) of length m < n and pay for it m·a coins; change some elements of the array by at most 1, and pay b coins…
题目链接:codeforces 797 E. Array Queries   题意:给你一个长度为n的数组a,和q个询问,每次询问为(p,k),相应的把p转换为p+a[p]+k,直到p > n为止,求每次询问要转换的次数. 题解:纯暴力会TLE,所以在k为根号100000范围内dp打表 dp[i][j]表示初始p为i, k为j,需要转换几次可以大于n. 状态转移方程:dp[i][j] = dp[i+a[i]+j] + 1 #include <cstdio> #include <al…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
http://blog.itpub.net/519536/viewspace-624176 有关层次查询之前的文章参考如下. [层次查询]Hierarchical Queries之"树的遍历" http://space.itpub.net/519536/viewspace-623809 [层次查询]Hierarchical Queries之LEVEL应用 http://space.itpub.net/519536/viewspace-623916 [层次查询]Hierarchical…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split…
[题目链接] http://codeforces.com/contest/451/problem/B [算法] 模拟 在序列中找到一段单调递增的子序列,将这段序列反转,然后判断序列是否变得单调递增,即可 [代码] #include<bits/stdc++.h> using namespace std; ; int i,n,l,r; bool flag; int a[MAXN]; int main() { scanf("%d",&n); ; i <= n; i+…