HUST Online Judge WebBoard
[ New Thread ]
Problem 1541 >> 答案
fanjiarui @ 2018-03-24 14:14:27
[ Quote ] [ Edit ] [ Delete ] 1#
#include<bits/stdc++.h>
using namespace std;
const int MAXL=100010;
const int INF=0x3f3f3f3f;
int L,S,T,n,stone[MAXL],dp[MAXL];
int main()
{
cin>>L>>S>>T>>n;
for (int i=1;i<=n;i++)
{
int x;
cin>>x;
++stone[x];
}
memset(dp,INF,sizeof(dp));
dp[0]=0;
for (int i=1;i<=L;i++)
{
for (int j=max(i-T,0);j<=i-S;j++)
dp[i]=min(dp[i],dp[j]);
if (dp[i]==INF)
dp[i]=0;
dp[i]+=stone[i];
}
cout<<dp[L]<<endl;
return 0;
}
[Top] [Previous Page] [Next Page]