Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
10s | 32768K | 1070 | 170 | Standard |
1 10 2 3 5 2 3 5 6 7
2Note:
Problem Source: 4th JLU Programming Contest
This problem is used for contest: 39
Submit / Problem List / Status / Discuss
这是一个让我非常蛋疼纠结的问题。首先在找递推关系式的时候出现了错误,再就是在编码的时候,弄错了一个地方,见标注
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int dp[2000+10];
int main()
{
freopen("in.txt","r",stdin);
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int l;
cin>>l;
int s,t,m;
cin>>s>>t>>m;
memset(dp,0,sizeof(dp));
for(int j=1;j<=m;j++)
{
int u;
cin>>u;
dp[u]=1;
}
for(int j=1;j<l+t;j++)
{
int mmin=1000000;
for(int k=j-t;k<=j-s;k++)
{
if(k<0)continue;//这句话必须有,否则就会造成这个循环的某些环节没有执行。。。。
if(mmin>dp[k])mmin=dp[k];
}
dp[j]+=mmin;
}
int mmin=10000000;
for(int j=l;j<l+t;j++)
{
if(mmin>dp[j])mmin=dp[j];
}
cout<<mmin<<endl;
}
return 0;
}