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 |
WRONG ANSWER!!!!!!!!大侠帮忙!!找了好久也找不到那错了,郁闷死了!!#include<iostream.h> #include<memory.h> struct or{ int start,end,num; }; int sum; int max,stop,n; or order[50]; int check[20]; void ser(int,int); void main() { int i; cin>>max>>stop>>n; while(max && stop && n){ sum=0; memset(order,0,sizeof(order)); memset(check,0,sizeof(check)); for(i=1;i<=n;i++){ cin>>order[i].start>>order[i].end>>order[i].num; } ser(1,0); cout<<sum<<endl; cin>>max>>stop>>n; } } void ser(int k,int earning) { int i,t=0; for(i=order[k].start;i<order[k].end;i++){ if(max-check[i]<order[k].num) t++; } if(t==0){ for(i=order[k].start;i<order[k].end;i++) check[i]+=order[k].num; earning+=(order[k].end-order[k].start)*order[k].num; sum=sum>earning ? sum:earning; if(k<n) ser(k+1,earning); for(i=order[k].start;i<order[k].end;i++) check[i]-=order[k].num; earning-=(order[k].end-order[k].start)*order[k].num; } if(k<n) ser(k+1,earning); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator