当前位置:网站首页>openjudge:校园食宿预订系统
openjudge:校园食宿预订系统
2022-07-28 05:18:00 【编程器系统】
描述
某校园为方便学生订餐,推出食堂预定系统。食宿平台会在前一天提供菜单,学生在开饭时间前可订餐。 食堂每天会推出m个菜,每个菜有固定的菜价和总份数,售卖份数不能超过总份数。 假设共有n个学生点餐,每个学生固定点3个菜,当点的菜售罄时, 学生就买不到这个菜了。 请根据学生预定记录,给出食堂总的预定收入 数据满足1 <= n <= 6000,3 <= m <= 6000,单品菜价不大于1000元,每个菜的配额不超过3000
输入
第一行两个整数n和m,代表有n个学生订餐,共有m个可选的菜
下面m行,每行三个元素,分别是菜名、售价和可提供量,保证菜名不重合,菜价为整数
下面n行,每行三个元素,表示这个学生点的三个菜的菜名
输出
一个整数,表示食堂的收入
样例输入
5 5 yangroupaomo 13 10 jituifan 7 5 luosifen 16 3 xinlamian 12 20 juruo_milktea 999 1 yangroupaomo luosifen juruo_milktea luosifen xinlamian jituifan yangroupaomo jituifan juruo_milktea jituifan xinlamian luosifen yangroupaomo yangroupaomo yangroupaomo
样例输出
1157
提示
如果用python做,要用字典,
如果用其它语言做,也要用类似的数据结构
否则会超时
名字长度范围没有给出,长度不会太离谱。请自己选用合适的办法确保这不是个问题
n, m = map(int,input().split())
t={}
for i in range(m):
s = input().split()
name, price, num =s[0], int(s[1]), int(s[2])
t[name]=[price,num]
total = 0
for i in range(n):
names = input().split()
for name in names:
if t[name][1]>0:
total += t[name][0]
t[name][1] -= 1
print(total)边栏推荐
- There is no crossover in the time period within 24 hours
- regular expression
- yandex robots txt
- Share several methods of managing flag bits in C program
- Non functional test
- 正则表达式
- PC side bug record
- 多线程进阶:volatile的作用以及实现原理
- (dark horse) MySQL beginner advanced notes (blogger lazy dog)
- BigDecimal rounds and retains two decimal places
猜你喜欢

Database date types are all 0

【计算机三级信息安全】信息安全保障概述

mysql 为查询结果增加序号

Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions

Multi module packaging: package: XXX does not exist
![[slam] lvi-sam analysis - Overview](/img/66/f15f6f574807b9a783e9321c71d422.png)
[slam] lvi-sam analysis - Overview

Offline loading of wkwebview and problems encountered

Mysql基本查询

正则表达式

科研论文写作方法:在方法部分添加分析和讨论说明自己的贡献和不同
随机推荐
mysql中使用list作为参数进行查询
How to compare long and integer and why to report errors
ResNet结构对比
多线程进阶:volatile的作用以及实现原理
Long和Integer如何进行比较,为什么报错
Google browser cannot open localhost:3000. If you open localhost, you will jump to the test address
How about ink cloud?
YUV to uiimage
regular expression
FusionGAN代码学习(一)
7. < tag string and API trade-offs> supplement: Sword finger offer 05. replace spaces
[slam] lvi-sam analysis - Overview
JVM note 4: Memory Model
First acquaintance with C language (2)
多模块打包:程序包:xxx不存在
Mysql处理遗留数据样例
【MySQL】MySQL时区问题、数据库时间相差8小时问题解决
Antd setfieldsvalue warning problem cannot use 'setfieldsvalue' until you use 'getfielddecorator' or
About localdatetime in swagger
蒸馏模型图