博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1026. Table Tennis (30)
阅读量:4072 次
发布时间:2019-05-25

本文共 4058 字,大约阅读时间需要 13 分钟。

1026. Table Tennis (30)

被卡5分未通过
时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest number. If all the tables are occupied, they will have to wait in a queue. It is assumed that every pair of players can play for at most 2 hours.

Your job is to count for everyone in queue their waiting time, and for each table the number of players it has served for the day.

One thing that makes this procedure a bit complicated is that the club reserves some tables for their VIP members. When a VIP table is open, the first VIP pair in the queue will have the priviledge to take it. However, if there is no VIP in the queue, the next pair of players can take it. On the other hand, if when it is the turn of a VIP pair, yet no VIP table is available, they can be assigned as any ordinary players.

Input Specification:

Each input file contains one test case. For each case, the first line contains an integer N (<=10000) - the total number of pairs of players. Then N lines follow, each contains 2 times and a VIP tag: HH:MM:SS - the arriving time, P - the playing time in minutes of a pair of players, and tag - which is 1 if they hold a VIP card, or 0 if not. It is guaranteed that the arriving time is between 08:00:00 and 21:00:00 while the club is open. It is assumed that no two customers arrives at the same time. Following the players' info, there are 2 positive integers: K (<=100) - the number of tables, and M (< K) - the number of VIP tables. The last line contains M table numbers.

Output Specification:

For each test case, first print the arriving time, serving time and the waiting time for each pair of players in the format shown by the sample. Then print in a line the number of players served by each table. Notice that the output must be listed in chronological order of the serving time. The waiting time must be rounded up to an integer minute(s). If one cannot get a table before the closing time, their information must NOT be printed.

Sample Input:
920:52:00 10 008:00:00 20 008:02:00 30 020:51:00 10 008:10:00 5 008:12:00 10 120:50:00 10 008:01:30 15 120:53:00 10 13 12
Sample Output:
08:00:00 08:00:00 008:01:30 08:01:30 008:02:00 08:02:00 008:12:00 08:16:30 508:10:00 08:20:00 1020:50:00 20:50:00 020:51:00 20:51:00 020:52:00 20:52:00 03 3 2

#include
#include
#include
#include
#include
#include
#include
using namespace std;struct Node{ int arrtime,servingTime,waitSecond,playMinuter,VipTag;};struct Table{ bool vipTag; int startTime,count; Table():vipTag(false),startTime(8*3600),count(0){};};int findTable(vector
Vip,int kind,int curTime){ int v1=-1,c1=-1; for (int i=0;i
o;void soluQue(vector
all,vector
*Vip,int kind,int curTime,vector
*VipQue){ for (int i=0; i<(*VipQue).size(); ++i) { if((*VipQue)[i].arrtime<=curTime){ int pos = findTable(*all, *Vip, kind, curTime); if(pos!=-1)//有空闲 { (*VipQue)[i].waitSecond = curTime - (*VipQue)[i].arrtime; (*VipQue)[i].servingTime = curTime; int x= (*VipQue)[i].playMinuter; x=x>120?120:x; (*all)[pos].startTime = x*60+ curTime; (*all)[pos].count++; o.push_back((*VipQue)[i]); (*VipQue).erase((*VipQue).begin()+i); i--; } }else break; }}int main(){ int customerNums,playTime,VipTag; string arriveTime; scanf("%d",&customerNums); vector
allCus(customerNums); vector
commonQue,VipQue; for (int i=0; i
>arriveTime>>playTime>>VipTag; int hh,mm,ss; sscanf(arriveTime.c_str(), "%d:%d:%d",&hh,&mm,&ss); allCus[i].arrtime = hh*60*60+mm*60+ss; allCus[i].playMinuter = playTime; allCus[i].VipTag = VipTag; } int tableNum,VipTableNum; scanf("%d %d",&tableNum,&VipTableNum); vector
*all,vector
vipTableID; for (int i = 0; i
>VipTag; vipTableID.push_back(VipTag-1); tables[VipTag-1].vipTag = true; } sort(vipTableID.begin(), vipTableID.end(), [](int a,int b){return a
tables(tableNum,Table()); vector

转载地址:http://emhji.baihongyu.com/

你可能感兴趣的文章
出现( linker command failed with exit code 1)错误总结
查看>>
iOS开发中一些常见的并行处理
查看>>
iOS获取手机的Mac地址
查看>>
ios7.1发布企业证书测试包的问题
查看>>
如何自定义iOS中的控件
查看>>
iOS 开发百问
查看>>
Mac环境下svn的使用
查看>>
github简单使用教程
查看>>
如何高效利用GitHub
查看>>
环境分支-git版本管理
查看>>
uni-app 全局变量
查看>>
js判断空对象的几种方法
查看>>
java 不用递归写tree
查看>>
springboot2 集成Hibernate JPA 用 声明式事物
查看>>
fhs-framework jetcache 缓存维护之自动清除缓存
查看>>
SpringBoot 动态编译 JAVA class 解决 jar in jar 的依赖问题
查看>>
fhs-framework springboot mybatis 解决表关联查询问题的关键方案-翻译服务
查看>>
ZUUL2 使用场景
查看>>
Spring AOP + Redis + 注解实现redis 分布式锁
查看>>
elastic-job 和springboot 集成干货
查看>>