- 过河
- 2015-01-17 21:24:27 @
测试数据 #0: WrongAnswer, time = 15 ms, mem = 536 KiB, score = 0
测试数据 #1: WrongAnswer, time = 0 ms, mem = 540 KiB, score = 0
测试数据 #2: Accepted, time = 0 ms, mem = 532 KiB, score = 10
测试数据 #3: RuntimeError, time = 0 ms, mem = 524 KiB, score = 0
测试数据 #4: RuntimeError, time = 0 ms, mem = 528 KiB, score = 0
测试数据 #5: RuntimeError, time = 0 ms, mem = 524 KiB, score = 0
测试数据 #6: RuntimeError, time = 0 ms, mem = 528 KiB, score = 0
测试数据 #7: RuntimeError, time = 0 ms, mem = 528 KiB, score = 0
测试数据 #8: RuntimeError, time = 0 ms, mem = 528 KiB, score = 0
测试数据 #9: Accepted, time = 0 ms, mem = 532 KiB, score = 10
RuntimeError, time = 15 ms, mem = 540 KiB, score = 20
#include<stdio.h>
#define MAX_INT 15000
#define GAP 105
int l,s,t,m;
int a[100]={0},x[MAX_INT]={0};
int ans=0;
void sort(int head,int tail)
{
int key;
int i=head,j=tail;
key=a[i];
if(head<tail)
{
while(i<j)
{
while(a[j]>=key&&i<j)j--;
if(i<j)a[i++]=a[j];
while(a[i]<=key&&i<j)i++;
if(i<j)a[j--]=a[i];
}
a[i]=key;
sort(head,i-1);
sort(i+1,tail);
}
}
int main(void)
{
scanf("%d%d%d%d",&l,&s,&t,&m);
int i,j,min;
for(i=0;i<=m-1;i++)scanf("%d",&a[i]);
if(s==t)
{
for(i=0;i<=m-1;i++)if(a[i]%t==0)ans++;
printf("%d",ans);return 0;
}
sort(0,m-1);
l=l>a[m-1]?a[m-1]:l;
j=a[0];
for(i=1;i<=m-1&&j<=l;i++)
{
x[j-1]=1;
while(a[i]-a[i-1]>GAP&&i<=m-1){j+=a[i]-a[i-1];i++;}
if(i<=m-1)j+=a[i]-a[i-1];
}
for(i=t;i<l;i++)
{
min=MAX_INT;
for(j=s;j<=t;j++)if(x[i-j+1]<min)min=x[i-j+1];
x[i]+=min;
}
printf("%d",x[l-1]);
return 0;
}
1 条评论
-
yugeyang LV 10 @ 2015-02-02 10:35:49
数组开小了吧
- 1