Drolca

Apologize To Drolca
随笔 - 28, 文章 - 1, 评论 - 6, 引用 - 0
数据加载中……

hdu 1103 悲剧了

 

#include <iostream>
#include 
<vector>
using namespace std;
const int maxn=1000;
struct group
{
 
int h,m,t;
}
;
group team[maxn];
int main()
{
 
int n2,n4,n6;
 
while(scanf("%d%d%d",&n2,&n4,&n6)!=EOF)
 
{
  
if(n2==0&&n4==0&&n6==0)
   
break;
  
char time[6];
  
int cnt=0;
  
while(scanf("%s",&time)!=EOF)
  
{
   
if(strcmp(time,"#")==0)
    
break;
    
int t;
   scanf(
"%d",&t);
   team[cnt].t
=t;
   team[cnt].h
=(time[0]-'0')*10+(time[1]-'0');
   team[cnt].m
=(time[3]-'0')*10+(time[4]-'0');
   cnt
++;
  }

  
int i,j;
  vector
<group> team12,team34,team56;
  __int64 sum
=0;
  
for(i=0;i<cnt;i++)
  
{
   
int len;
   group tmp;
   
if(team[i].t==1||team[i].t==2)
   
{

    len
=team12.size();
    
if(len<n2)
    
{
     team12.push_back(team[i]);
     sum
+=team[i].t;
     
continue;
    }

        
     tmp
=team12.front();
     
int usetime=(team[i].h-tmp.h)*60+(team[i].m-tmp.m);
     group fuck;
     fuck
=team12.back();
     
if(((team[i].h-fuck.h)*60+(team[i].m-fuck.m))<=0)
         
continue;
     
if(usetime<0)
         
continue;
     
if(usetime<30)
     
{
     team[i].h
=tmp.h+(tmp.m+30)/60;
     team[i].m
=(tmp.m+30)%60;
     }

      team12.erase(team12.begin());
      team12.push_back(team[i]);
      sum
+=team[i].t;
   }

 

   
if(team[i].t==3||team[i].t==4)
   
{
    len
=team34.size();
    
if(len<n4)
    
{
     team34.push_back(team[i]);
     sum
+=team[i].t;
     
continue;
    }


     tmp
=team34.front();
     
int usetime=(team[i].h-tmp.h)*60+(team[i].m-tmp.m);
          group fuck;
     fuck
=team12.back();
     
if(((team[i].h-fuck.h)*60+(team[i].m-fuck.m))<=0)
         
continue;
     
if(usetime<0)
         
continue;
      
if(usetime<30)
     
{
     team[i].h
=tmp.h+(tmp.m+30)/60;
     team[i].m
=(tmp.m+30)%60;
     }

      team34.erase(team34.begin());
      team34.push_back(team[i]);
      sum
+=team[i].t;
   }



   
if(team[i].t==5||team[i].t==6)
   
{
    len
=team56.size();
    
if(len<n6)
    
{
     team56.push_back(team[i]);
     sum
+=team[i].t;
     
continue;
    }

 
     tmp
=team56.front();
     
int usetime=(team[i].h-tmp.h)*60+(team[i].m-tmp.m);
          group fuck;
     fuck
=team12.back();
     
if(((team[i].h-fuck.h)*60+(team[i].m-fuck.m))<=0)
         
continue;
     
if(usetime<0)
         
continue;
      
if(usetime<30)
     
{
     team[i].h
=tmp.h+(tmp.m+30)/60;
     team[i].m
=(tmp.m+30)%60;
     }

      team56.erase(team56.begin());
      team56.push_back(team[i]);
      sum
+=team[i].t;
   }

  }

  printf(
"%I64d\n",sum);
 }

 
return 0;
}

posted on 2009-09-18 00:29 Drolca 阅读(228) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理