1026 Table Tennis Python实现

1.占用时间不能超过两小时
2.vip优先选择vip空桌,而非编号最小的空桌

def stot(w:str):h=int(w[:2])m=int(w[3:5])s=int(w[6:])return (h*60+m)*60+s
def ttos(x:int):res=""h=str(x//3600)res+="0"+h+":" if len(h)==1 else h+":"x%=3600m=str(x//60)res+="0"+m+":" if len(m)==1 else m+":"s=str(x%60)res += "0" + s if len(s) == 1 else sreturn res
def next():min = [-1, 22 * 3600]for x in range(m):if table[x] == []:min = [x, 8 * 3600]breakelif table[x][-1] < min[1]:min = [x, table[x][-1]]return min
def nextVip():min = [-1, 22 * 3600]for x in range(m):if table[x] == [] and x in tvip:min = [x, 8 * 3600]return minelif table[x] == [] and min[0]==-1:min = [x, 8 * 3600]if min[0]!=-1:return minfor x in range(m):if table[x][-1] < min[1]:min = [x, table[x][-1]]return min
n=int(input())
ordq=[]
vip=[]
play={}
for _ in range(n):atime,p,tag=input().split()atime=stot(atime)p=int(p)*60ordq.append(atime)if tag=="1":vip.append(atime)play[atime]=p if p<=7200 else 7200
m,vm=[int(x) for x in input().split()]
tvip=[int(x)-1 for x in input().split()]
ordq=sorted(ordq)
vip=sorted(vip)
table=[]
for _ in range(m):table.append([])
while len(ordq)!=0:if ordq[0] in vip:min=nextVip()else:min=next()if min[0] in tvip and (vip==[] or vip[0]>min[1]):atime=ordq.pop(0)if atime in vip:vip.remove(atime)elif min[0] in tvip and vip[0]<=min[1]:atime=vip.pop(0)ordq.remove(atime)else:atime=ordq.pop(0)if atime in vip:vip.remove(atime)stime=min[1] if min[1]>atime else atimewtime=(stime-atime)/60+0.5etime = stime + play[atime]if stime>=21*3600:breakprint(ttos(atime),ttos(stime),str(int(wtime)))table[min[0]].append(etime)
print(" ".join([str(len(x)) for x in table]))

1026 Table Tennis Python实现相关推荐

  1. 1026 Table Tennis (30 分)模拟排列问题

    题目 A table tennis club has N tables available to the public. The tables are numbered from 1 to N. Fo ...

  2. 1026. Table Tennis (30)

    题目如下: A table tennis club has N tables available to the public. The tables are numbered from 1 to N. ...

  3. 【PAT甲级 模拟 测试点0、3、4、5、7、8分析】1026 Table Tennis (30 分)

    这篇文章帮我解决了测试点5.7 测试点分析都在代码注释里了 #include<bits/stdc++.h> using namespace std;int N, K, M; // 球友对的 ...

  4. PAT 1026 Table Tennis (30分)

    蛮复杂的一道模拟题 需要注意的点挺多的: 1.优先级问题(vip桌子的安排) 2.playtime规定在2h之内,超过2h按2h计算 3.servingtime等于或大于21点的不输出 #includ ...

  5. 1026 Table Tennis (30分)

    据说是PAT最难的一道模拟题,情况很复杂,第二次做了,依旧是折磨人的小妖精(* ̄︶ ̄). 这次主要是栽在条件判断上了,一定要小心数组越界!而且这种错很难找 (代码里※标注的地方,就是我找错找了好久的地 ...

  6. 1026 Table Tennis (30 分) 未完成【难度: 难 / 知识点: 模拟】

    https://pintia.cn/problem-sets/994805342720868352/problems/994805472333250560

  7. Codeforces Round #443 (Div. 2) B. Table Tennis

    Codeforces Round #443 (Div. 2) B. Table Tennis     879B 啊啊啊啊啊啊 做的时候太天真了--一开始的直觉是对的--orz后来想多了,pretest ...

  8. PAT----A1026 Table Tennis (30point(s))

    A1026 Table Tennis (30point(s)) 花了好长时间都没ac,还差第五个测试点通不过,没办法了,先放着. 题意 优先安排id小的桌子.注意如果vip到了,优先安排vip桌子: ...

  9. Pat(Advanced Level)Practice--1026(Table Tennis)

    Pat1026代码 题目描述:A table tennis club has N tables available to the public. The tables are numbered fro ...

最新文章

  1. FLASH处理图像的移动、缩放、旋转、颜色变换的类推荐。
  2. MATLAB从入门到精通-机械动力学仿真-Amesim仿真实例:对于任意的外力作用下的机械动力学仿真
  3. python谷歌网页爬虫_python爬虫入门01:教你在 Chrome 浏览器轻松抓包
  4. 狼奔权限管理系统[开源]
  5. 李名洋(1983-),男,中国电信股份有限公司云计算分公司数据分析师。
  6. groovy 对 list 排序
  7. mysql运用索引写出高效sql_从SQL Server到MySql(5) : 高性能的MySql 索引策略
  8. day20: zip压缩工具及打包工具介绍
  9. 中国用量子计算机仿生生物,中国科学技术大学研制一种可持续生物合成仿生多层级太阳能蒸汽发生器...
  10. SAP GUI 750 下载链接
  11. 关于iostream与using namespace std 的解析
  12. 局域网文件传输方式分析
  13. SSM框架---开发免费小说网站(h5+电脑端)
  14. outlook连接谷歌企业邮箱(转)
  15. rsync+crontab实现定时备份
  16. 大乐斗2服务器维护,腾讯《QQ宠物》、《乐斗Ⅱ》正式停止运营
  17. STM32 F103 外部晶振8M改为12M
  18. 【阿里巴巴】数据开发暑期实习生面试面经 技术面 已凉凉
  19. 日本机器自动化初创企业Cinnamon获天使轮融资
  20. 利用AI+大数据的方式分析恶意样本(十三)

热门文章

  1. Python之菲波那切数列
  2. 聊一聊SLAM核心算法之ESKF多传感器融合算法
  3. 考研期间的避雷贴和你会头疼的方面
  4. [Android APP] ios和android都领取不到的假口令红包app和源码
  5. GQC的HIL启动流程
  6. magic系统能升级鸿蒙系统吗,magic ui4.0是鸿蒙系统吗_magic ui4.0是不是鸿蒙系统
  7. 小程序开发—发布流程及注意事项
  8. 请翻译成英语:同理,上述结果为3
  9. 利用OpenGL的多视区分别在4个视区内显示空间四面体的透视投影图、主视图、俯视图、侧视图
  10. 搜狐要报道英朗和408上市啦