标签:
10
2 3 5
2 3 5 6 7
2
#include<iostream> #include<cstdio> #include<algorithm> #define maxint 105 #define maxn 700005 using namespace std; int l,s,t,m,nl; int dp[maxn],stone[maxn],vis[maxn],ans; bool cmp(int a,int b){ return a<b; } int main(){ cin>>l>>s>>t>>m; int tmp,next,last = 0,cut = 0; for(int i = 1;i <= m;i++){ scanf("%d",&tmp); stone[i] = tmp; } sort(stone+1,stone+1+m,cmp); stone[m+1] = l; for(int i = 1;i <= m+1;i++){ tmp = stone[i]; tmp -= cut; int river = tmp - last - 1; int rec = river; river %= 11007; tmp = last+river+1; vis[tmp] = 1; last = tmp; if(i == m+1) l = tmp; } for(int i = 1;i <= l;i++){ dp[i] = maxint; } ans = maxint; for(int i = 0;i < l;i++){ if(vis[i]){ dp[i]++; } for(int j = s;j <= t;j++){ if(i+j>=l){ ans = min(ans,dp[i]); break; } dp[i+j] = dp[i+j] > dp[i] ? dp[i] : dp[i+j]; } } cout<<ans; return 0; }
标签:
原文地址:http://www.cnblogs.com/hyfer/p/5811900.html