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),在高级操作 ...
随机推荐
- jmeter压测
一般压测时间:10-15分钟 这些并发用户一直在请求. 稳定性测试:一周 2天 衡量性能好坏的指标: tps 服务端每秒钟能处理的请求数 rt响应时间 就是你从发出请求到服务器端返回所需的时间. ...
- Requires: libc.so.6(GLIBC_2.14)(64bit)
centos6 - CentOS 6 - libc.so.6(GLIBC_2.14)(64bit) is needed by - Server Faulthttps://serverfault.com ...
- jmeter压测参数设定(转)
jmeter压测参数设定 一.基本公式 线程数 = QPS * time: 注:QPS--每秒完成请求的个数:time--每个请求响应完成平均需要时间: 故QPS * time就是所有请求完成响应所需 ...
- vuex的购物车效果 index.js
import Vue from 'vue'; import Vuex, { Store } from 'vuex'; import { stat } from 'fs'; Vue.use(Vuex); ...
- idea 创建的spingmvc 引入jquery后jquery函数始终不执行的原因
- python爬虫之短信报警
1 import smtplib import email.mime.multipart import email.mime.text def send_email(content=''): &quo ...
- Front-end Job Interview Questions
Front-end Job Interview Questions 前端面试 https://github.com/h5bp/Front-end-Developer-Interview-Questio ...
- jquery和js的几种页面加载函数的方法以及执行顺序
参考博客:http://www.cnblogs.com/itslives-com/p/4646790.html https://www.cnblogs.com/james641/p/783837 ...
- Echarts使用Ajax异步获得数据的前端json格式转化问题
利用Ajax获取后台传来的data,官网都有example 但如果后台传来的数据是String格式的,则应该在Ajax的done方法中第一句加上格式转换的语句 data = JSON.parse(da ...
- 百度云虚拟主机配置 Thinkphp5.1
材料 服务器:百度云虚拟主机(nginx+php7.0+linux) Thinkphp 5.1 问题 百度云默认目录为/webroot,但是我们的需求是将项目存放到/webroot/public下面. ...