Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:我把所有的,注意是所有的测试数据全部过了,还写了文件来验证。。全部一样,为啥还是不对

Posted by dreamspark at 2010-08-10 00:08:53 on Problem 1042
In Reply To:我把所有的,注意是所有的测试数据全部过了,还写了文件来验证。。全部一样,为啥还是不对 Posted by:boatswain at 2010-08-07 19:23:21
> #include <iostream>
> #include <stdio.h>
> #include <functional>
> #include <string.h>
> #include <algorithm>
> #include <queue>
> using namespace std;
> typedef struct Node
> {
>   int fi,ti,di;int loc;int time;
> }node;
> node lake[25];
> node temp[25];
> node temp2[25];
> node boat;
> int n,h,maxtime;int maxfish;
> bool operator<(const Node z,const Node x)
> {if(x.fi==z.fi) return z.loc>x.loc;return x.fi>z.fi;}
> void fish()
> {
>   memcpy(temp,lake,sizeof(temp));
>   memcpy(temp2,lake,sizeof(temp2));
>   maxfish=0;int curfish=0;
>   int tt;int _i,_d,_t,_f;
>   priority_queue<Node> q;
>   for(int k=1;k<=n;k++)
>   { curfish=0;
>     tt=maxtime;
>     for(int i=1;i<=k;i++){tt-=temp[i].ti*5; temp[i]=lake[i]; q.push(temp[i]);}
>     while(tt>0)
>     {
>      boat=q.top();
>      q.pop();
>      if(boat.fi==0) break;
>      curfish+=boat.fi;
>      _i=boat.loc;
>      temp[_i].time+=5;
>      temp[_i].fi-=boat.di;
>      if(temp[_i].fi<0) temp[_i].fi=0;
>      tt-=5;
>      q.push(temp[_i]);
>     }
>     if(tt>0) temp[1].time+=tt;
>      if(curfish>maxfish) 
>      {
>       maxfish=curfish;
>       memcpy(temp2,temp,sizeof(temp2));
>      }
>      else if(curfish==maxfish)
>      {
>           for(int i=1;i<=n;i++)
>           {
>            if(temp[i].time>temp2[i].time)
>            {
>              memcpy(temp2,temp,sizeof(lake));
>              break;
>            }
>           }
>      }
> 
>      while(!q.empty())
>      q.pop();
>   }
> }
> int main()
> {
>     scanf("%d",&n);
>     while(n!=0)
>     { memset(temp2,0,sizeof(temp2));
>       memset(lake,0,sizeof(lake));
>       memset(temp,0,sizeof(temp));
>       scanf("%d",&h);
>       maxtime=h*60;
>       for(int i=1;i<=n;i++){ scanf("%d",&lake[i].fi);lake[i].loc=i;}
>       for(int i=1;i<=n;i++)  scanf("%d",&lake[i].di);
>       for(int i=2;i<=n;i++)  scanf("%d",&lake[i].ti);
>       fish();
>       memcpy(lake,temp2,sizeof(lake));
>       int i;
> 
>       for(i=1;i<n;i++)
>       printf("%d, ",lake[i].time);
>       printf("%d\n",lake[i].time);
>       printf("Number of fish expected: %d\n\n",maxfish);
>       scanf("%d",&n);
>       
>     }
>     return 0;
> }
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator