HR_Array Manipulation
第一版有7个时间超限,优化成了第二版:
1:
#!/bin/python3 import math
import os
import random
import re
import sys # Complete the arrayManipulation function below.
def arrayManipulation(n, queries):
# n is lenth m is operatation
m = len(queries)
arr = [0]*n
for i in range(m):
start = queries[i][0]
end = queries[i][1]
for j in range (start -1, end):
arr[j] += queries[i][2]
return max(arr)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w') nm = input().split() n = int(nm[0]) m = int(nm[1]) queries = [] for _ in range(m):
queries.append(list(map(int, input().rstrip().split()))) result = arrayManipulation(n, queries) fptr.write(str(result) + '\n') fptr.close()
2:
#!/bin/python3 import math
import os
import random
import re
import sys # Complete the arrayManipulation function below.
def arrayManipulation(n, queries):
# n is lenth m is operatation
m = len(queries)
arr = [0]*(n+1)
for i in range(m):
start = queries[i][0]
end = queries[i][1]
arr[start - 1] += queries[i][2]
if (end <=len(arr)):
arr[end] -= queries[i][2] max =x =0
for i in arr:
x = x + i
if (max < x) : max =x
return max
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w') nm = input().split() n = int(nm[0]) m = int(nm[1]) queries = [] for _ in range(m):
queries.append(list(map(int, input().rstrip().split()))) result = arrayManipulation(n, queries) fptr.write(str(result) + '\n') fptr.close()
HR_Array Manipulation的更多相关文章
- backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized.
昨天在检查YourSQLDba备份时,发现有台数据库做备份时出现了下面错误信息,如下所示: <Exec> <ctx>yMaint.ShrinkLog</ctx> ...
- Hololens开发笔记之Gesture手势识别(Manipulation手势控制物体旋转)
Manipulation gesture:保持点击手势,在3D世界中绝对运动 当你想要全息图像1:1响应用户手部移动时,操纵手势能被用于移动.缩放或旋转全息图像.如此的一个用处是使得用户可以在世界中绘 ...
- Hololens开发笔记之Gesture手势识别(Manipulation手势控制物体平移)
Manipulation gesture:保持点击手势,在3D世界中绝对运动 当你想要全息图像1:1响应用户手部移动时,操纵手势能被用于移动.缩放或旋转全息图像.如此的一个用处是使得用户可以在世界中绘 ...
- Track files and folders manipulation in Windows
The scenario is about Business Secret and our client do worry about data leakage. They want to know ...
- Data manipulation primitives in R and Python
Data manipulation primitives in R and Python Both R and Python are incredibly good tools to manipula ...
- VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0 字符串模拟
C. String Manipulation 1.0 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/pr ...
- Bash String Manipulation Examples – Length, Substring, Find and Replace--reference
In bash shell, when you use a dollar sign followed by a variable name, shell expands the variable wi ...
- windows phone 之手势识别(Manipulation)
在Windows Phone 7的多触摸屏上可以检测到至少四根同时存在的手指,并且一起操作使触摸屏充分发挥效果. 在silverlight开发中通过事件来实现触屏事件的检测,包括低级别的和高级别的接口 ...
- WPF Multi-Touch 开发:高级触屏操作(Manipulation)
原文 WPF Multi-Touch 开发:高级触屏操作(Manipulation) 在上一篇中我们对基础触控操作有了初步了解,本篇将继续介绍触碰控制的高级操作(Manipulation),在高级操作 ...
随机推荐
- 搭建RISC-V错误记录
错误:riscv64-unknown-elf-gcc: Command not found 解决办法:将riscv64-unknown-elf-gcc文件拷贝到根目录的/bin目录下. 原因是make ...
- #Leetcode# 1016. Binary String With Substrings Representing 1 To N
https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/ Given a binary stri ...
- js判断手机机型,然后进行相对应的操作
我们通过浏览器内置的userAgent来判断手机机型. 具体代码如下: var u = navigator.userAgent, app = navigator.appVersion; if(/App ...
- oracle创建表空间、创建用户、授权角色和导入导出用户数据
使用数据库管理员身份登录 -- log as sysdba sqlplus / as sysdba; 创建临时表空间 -- create temporary tablespace create tem ...
- vue-cli 上传图片上传到OSS(阿里云)
https://help.aliyun.com/document_detail/32068.html?spm=5176.doc32069.6.304.Qc4SUs(看) https://help.al ...
- js 解决中文乱码的问题
1.对象 request response 对象setCharacterEncoding=UTF-8 1 <%@ page language="java" contentTy ...
- java学习之—链表(1)
/** * 单链表操作 * Create by Administrator * 2018/6/14 0014 * 下午 2:05 **/ public class Link { public int ...
- kibana简单使用——elaticsearch的文档,索引的CRUD操作
1.初始化索引: #number_of_shards:分片的数量,mo'ren默认为5 #number_of_replicas:副本副本的副本的数量 #shards一旦设置不能修改 PUT lagou ...
- 关于IWMS后台登录问题总结
一.登录后台,点击登录无反应: 1.是因为网站文件夹没有权限,需要右击文件夹,将只读勾选去掉 2.在安全中加入Everyone对象. 二.登录后台后,左边显示不全,是因为会员权限不够,需要给权限.
- 关于 flask 实现数据库迁移以后 如何根据创建的模型类添加新的表?
在此之前 我们先说一下常规的flask运用第三方扩展来实现数据库的迁移的三个步骤以及每步的目的. 数据库的迁移的三个步骤:(cd 到run.py所在路径) python run.py db init ...