We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Array Manipulation
Array Manipulation
Sort by
recency
|
2494 Discussions
|
Please Login in order to post a comment
TypeScript
Could someone clarify what the question means? Either it’s not well-worded, or my understanding is lacking, and I'm feeling confused.
What in the world is this problem asking? Seems poorly defined IMO
I have used in Prefix method
long [] arr= new long[n+2];
}
import sys queries=sys.stdin.read().strip().split() it=iter(queries) n=int(next(it)) q=int(next(it)) arr = [0] * (n+2)
for i in range(q): a = int(next(it)) b = int(next(it)) k = int(next(it)) arr[ a ] += k arr[ b +1] -= k
max_value = 0 current = 0 for val in arr: current += val max_value = max(max_value, current)
print(max_value)