HDU ACM 1103 Flo's Restaurant
来源:互联网 发布:天津伊势丹mac是正品吗 编辑:程序博客网 时间:2024/05/12 00:29
分析:借助STL的min_element实现。每次更新最先被占用的桌子,具体见注释。
#include<iostream>#include<algorithm>using namespace std;int main(){int A,B,C;char s[10];int a[102],b[102],c[102];int curtime,count,ans;int *p; //桌子最先空闲时间while(cin>>A>>B>>C,A+B+C){memset(a,0,sizeof(a));memset(b,0,sizeof(b));memset(c,0,sizeof(c));ans=0;while(cin>>s && s[0]!='#'){curtime=(s[0]-'0')*10+(s[1]-'0');curtime=curtime*60+(s[3]-'0')*10+(s[4]-'0');cin>>count;if(count==1||count==2){p=min_element(a,a+A); //取得最小值(也即桌子的最早空余时间)if(*p<=curtime+30) //顾客等30分钟后是否有座位{if(*p<=curtime) *p=curtime+30; //最先被占用的桌子的顾客已经离开了,新顾客可以入座else *p+=30; //新顾客还需等待ans+=count;}}if(count==3||count==4){p=min_element(b,b+B); //取得最小值(也即桌子的最早空余时间)if(*p<=curtime+30) //顾客等30分钟后是否有座位{if(*p<=curtime) *p=curtime+30; //最先被占用的桌子的顾客已经离开了,新顾客可以入座else *p+=30; //新顾客还需等待ans+=count;}}if(count==5||count==6){p=min_element(c,c+C); //取得最小值(也即桌子的最早空余时间)if(*p<=curtime+30) //顾客等30分钟后是否有座位{if(*p<=curtime) *p=curtime+30; //最先被占用的桌子的顾客已经离开了,新顾客可以入座else *p+=30; //新顾客还需等待ans+=count;}}}cout<<ans<<endl;}return 0;}
0 0
- HDU ACM 1103 Flo's Restaurant
- HDU 1103 Flo's Restaurant
- HDU 1103 Flo's Restaurant
- 模拟 hdu 1103 Flo's Restaurant
- hdu 1103 flo restaurant
- HDU 1103 Flo's Restaurant(模拟+优先队列)
- 杭电 1103 Flo's Restaurant
- Flo's Restaurant
- HDU 1103.Flo's Restaurant【模拟】【3月2】
- poj 2424 Flo's Restaurant
- poj 2424 Flo's Restaurant
- HDU1103 Flo's Restaurant 【模拟】
- poj 2424 Flo's Restaurant
- poj 2424 Flo's Restaurant
- [ACM] HDU 4883 TIANKENG’s restaurant
- 【HDU1103】【模拟】Flo's Restaurant 餐厅吃饭排桌子
- hdu TIANKENG’s restaurant
- TIANKENG’s restaurant HDU
- Android中自定义下拉样式Spinner
- python 5 条件判断和循环
- java.sql.SQLException: Access denied for user 'sa'@'localhost' (using password: YES)
- ios自适应布局
- Android 系统电话管理机制与架构
- HDU ACM 1103 Flo's Restaurant
- MP4box常用命令
- android 内存管理机制
- hdu 1814 Peaceful Commission(2-SAT 输出字典序最小的解)
- Xcode下载
- UVA - 10396 Vampire Numbers 暴力+打表
- tomcat manager app 和 host maganger
- CF 148D. Bag of mice[概率dp]
- Ecshop与Jquery冲突的完美解决方案