[HackerRank][Python3] Array Manipulation
2018. 7. 9. 13:54 |
프로그래밍/HackerRank
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)
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Strings: Making Anagrams (0) | 2018.07.15 |
---|---|
[HackerRank][Python3] Count Triplets (0) | 2018.07.13 |
[HackerRank][Python3] Frequency Queries (0) | 2018.07.13 |
[HackerRank][Python3] Sherlock and Anagrams (0) | 2018.07.12 |
[HackerRank][Python3] New Year Chaos (0) | 2018.07.07 |
[HackerRank][Python3] Minimum Swaps 2 (0) | 2018.07.06 |
[HackerRank][Python3] Is This a Binary Search Tree? (2) | 2018.06.25 |
[HackerRank][Python3] Candies (0) | 2018.06.14 |
최근에 달린 댓글 최근에 달린 댓글