| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
?????太奇怪了,这给这么多测试数据我都通过了,怎么提交就错了呢???In Reply To:谁能给两组测试数据?????????????多谢!!! Posted by:burningice at 2004-02-28 20:05:04 难道还有其它BT数据吗??
我都与上面给的数据一一对应,看了.没有差别啊~~~为什么提交就WR?.
我的烂代码如下:
#include "stdio.h"
int T;
long price;
int A[8];
struct orders{
int from;
int to;
int num;
} orders[23];
long search(int k,int position,int A[])
{ int i,j;
long nowprice[2],all;
int a[8],zhan;
for(i = 0;i < 8;i ++)
a[i] = A[i];
if(k >= T) return 0;
zhan = orders[k].from;
for( j = 0; j <= zhan;j ++)
{
position += a[j];
a[j] = 0;
}
if( orders[k].num != 0 && position >= orders[k].num)
{
a[orders[k].to] += orders[k].num;
nowprice[0] = orders[k].num * ( orders[k].to - orders[k].from ) + search( k+1, position-orders[k].num , a);
a[orders[k].to] -= orders[k].num;
}
all = 0;
for( i = k+1;i < T;i ++)
all += orders[i].num * ( orders[i].to - orders[i].from );
if(all > nowprice[0])
nowprice[1] = search( k+1 , position , a);
return ( nowprice[0] > nowprice[1]? nowprice[0] : nowprice[1] );
}
int main()
{ int i , j , n , m , t ;
while( scanf("%d %d %d",&n,&m,&T),n||m||T)
{ for(i = 0;i <= m;i ++)
A[i] = 0;
for(i = 0;i < T;i ++)
scanf("%d %d %d",&orders[i].from , &orders[i].to , &orders[i].num);
for( i = 0;i < T-1;i ++)
for( j = 0;j< T - 1 - i;j ++)
if( orders[j].from > orders[j+1].from)
{ t = orders[j].from ; orders[j].from = orders[j+1].from; orders[j+1].from = t;
t = orders[j].to ; orders[j].to = orders[j+1].to ; orders[j+1].to = t;
t = orders[j].num ; orders[j].num = orders[j+1].num ; orders[j+1].num = t;
}
price = search( 0 , n , A );
printf("%ld\n", price);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator