프로그래밍/HackerRank
[HackerRank][Python3] Array Manipulation
snoopybox
2018. 7. 9. 13:54
Problem :
https://www.hackerrank.com/challenges/crush/problem
My Solution :
#!/usr/bin/env python3 def arrayManipulation(n, queries): arr = [0]*(n+1) M, S = 0, 0 for line in queries: a, b, k = line arr[a-1] += k arr[b] -= k for delta in arr: S += delta M = max(M, S) return M n, m = map(int, input().split()) queries = [] for _ in range(m): queries.append(list(map(int, input().rstrip().split()))) result = arrayManipulation(n, queries) print(result)