题面:[POI2014]PTA-Little Bird 题解: N<=1e6 Q<=25F[i]表示到达第i棵树时需要消耗的最小体力值F[i]=min(F[i],F[j]+(D[j]>=D[i])) (j>=i-K)使用单调队列维护越小的越优,在写单调队列时,让F值最小的数越前因为F[i]-F[j]最多等于1然后如果F值相同,则D越大的越优,因为D越大,后面不用+1的概率越大大概就是这样 代码: #include<cstdio> #include<cstring&…
f(i)=min{f(j)+(D(j)<=D(i))} (max(1,i-k)<=j<=i) 有两个变量,很难用单调队列,但是(引用): 如果fi<fj,i一定比j优秀.因为如果heighti≥heightj就不用说了,如果heighti<heightj,i可以花1的代价跳到高的地方,顶多和j一样,不会比j差. 如果fi=fj,那当然就是谁的height高谁优秀. 双关键字搞一下就好了. #include<cstdio> using namespace std;…
3831: [Poi2014]Little Bird Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 505  Solved: 322[Submit][Status][Discuss] Description In the Byteotian Line Forest there are   trees in a row. On top of the first one, there is a little bird who would like t…
3831: [Poi2014]Little Bird Time Limit: 20 Sec  Memory Limit: 128 MB Description In the Byteotian Line Forest there are   trees in a row. On top of the first one, there is a little bird who would like to fly over to the top of the last tree. Being in…
设f[i]表示到i最少休息次数,f[i]=min(f[j]+(h[j]<=a[i])),i-k<=j<i,单调队列优化DP #include<cstdio> #define N 1000010 inline void read(int&a){char c;while(!(((c=getchar())>='0')&&(c<='9')));a=c-'0';while(((c=getchar())>='0')&&(c<…
[BZOJ3831][Poi2014]Little Bird Description In the Byteotian Line Forest there are   trees in a row. On top of the first one, there is a little bird who would like to fly over to the top of the last tree. Being in fact very little, the bird might lack…
原文地址:http://www.cnblogs.com/GXZlegend/p/6826475.html 题目描述 In the Byteotian Line Forest there are   trees in a row. On top of the first one, there is a little bird who would like to fly over to the top of the last tree. Being in fact very little, the…
P3572 [POI2014]PTA-Little Bird 题目描述 In the Byteotian Line Forest there are nn trees in a row. On top of the first one, there is a little bird who would like to fly over to the top of the last tree. Being in fact very little, the bird might lack the s…
传送门 DP方程 f[i] = f[j] + (a[j] <= a[i]) ( i - k < j < i ) 要使 f[i] 最小,需要等号后面的值最小,可以用单调队列来维护. 至于如何维护,具体看代码. ——代码 #include <cstdio> ; int n, k, Q, h, t; int a[MAXN], q[MAXN], f[MAXN]; inline bool cmp(int x, int y) { return f[x] > f[y] || (f[x…
BZOJ_3831_[Poi2014]Little Bird_单调队列优化DP Description 有一排n棵树,第i棵树的高度是Di. MHY要从第一棵树到第n棵树去找他的妹子玩. 如果MHY在第i棵树,那么他可以跳到第i+1,i+2,...,i+k棵树. 如果MHY跳到一棵不矮于当前树的树,那么他的劳累值会+1,否则不会. 为了有体力和妹子玩,MHY要最小化劳累值. Input There is a single integer N(2<=N<=1 000 000) in the fi…