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…
[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…
从1开始,跳到比当前矮的不消耗体力,否则消耗一点体力,每次询问有一个步伐限制,求每次最少耗费多少体力 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int N=1e6+10; #define int long long int a[N],dp[N],q[N],l,r=1; int n,m,k; inlin…
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…
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;…
设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<…
洛谷题面传送门 考虑一个平凡的 DP:我们设 \(dp_i\) 表示前 \(i\) 辆车一来一回所需的最小时间. 注意到我们每次肯定会让某一段连续的火车一趟过去又一趟回来,故转移可以枚举上一段结束位置,设为 \(j\),那么有转移 \[dp_i=\min\limits_{j}\{\max(dp_j+i-j-1,a_i)+2s+i-j-1\} \] 在这里我们不妨假设 \(a_i<a_{i+1}\),这个可以通过从左到右扫一遍并执行 \(a_i\leftarrow\max(a_{i-1}+1,a_…
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…
题面:[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&…