Python刷题集合——瞌睡
2020-02-02 17:22
417 查看
牛客网-瞌睡
Python 代码
def f(n,k,a,t): # k>=n,整节课都保持清醒 if k>=n: return sum(a) """ #将评分分为两部分: #(1)一部分是没有叫醒服务,得到的评分,cur #(2)一部分是叫醒一次,额外得到的评分,other """ cur=0 other=[0] for i in range(n): cur+=a[i]*t[i] other.append(other[i]+a[i]*(1-t[i])) M=0 for i in range(n): if i+k-1<n: M=max(M,other[i+k]-other[i]) else: #越界 M=max(M,other[-1]-other[i]) return cur+M n,k=list(map(int,input().split())) a=list(map(int,input().split())) t=list(map(int,input().split())) print(f(n,k,a,t))
- 点赞 1
- 收藏
- 分享
- 文章举报
相关文章推荐
- Python 语言及其应用 Chapter_3_Note_2 容器_列表_元组_字典_集合
- Python 中的 集合类型 --- set
- Python基础-列表_元组_字典_集合
- Python中的 set集合 、类型转换 、列表生成式 、迭代器与可迭代对象 、生成器 、函数
- Python学习20:集合类型(set)
- python 元组、字符串及中文乱码处理、字典、集合详解
- Python列表推导式、字典推导式与集合推导式用法实例分析
- Python基础【数据结构:列表 | 元组 | 集合 | 字典】
- python 集合类型 tuple 与 list
- Python 性能优化【2】 -- 高效的使用序列与字典、集合
- Python数据类型:集合
- Python的集合框架
- python教程 集合set操作
- python random 从集合中随机选择元素
- 百度2017春招笔试真题编程题集合:度度熊回家 [python]
- Python学习笔记7:Python字典和集合
- ubuntu下python问题集合
- python 集合
- Python集合(set)类型的操作
- Python 列表 元组 字典 集合