PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FT0000239. Thao tác trên mảng (Array Manipulation)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Thao tác trên mảng (Array Manipulation)
Array Manipulation
Source: HackerRank
Version: Phuoc Hung OJ Extended
Problem Statement
Initially, an array has elements, indexed from through , and every element is .
Process operations in the given order. An operation consists of three integers , , and increases every element at positions by . Both endpoints are included; positions outside the interval are unchanged.
After all operations have been performed, find the largest value among the array elements.
Input
- The first line contains integers : the array length and the operation count.
- Each of the next lines contains integers , denoting the inclusive update interval and the amount added to every element in that interval. Array indexing starts at .
Output
Print one integer: the maximum array value after all operations.
Subtasks
- Subtask 1 (20 points): ; ; and for every operation.
- Subtask 2 (30 points): ; ; and for every operation.
- Subtask 3 (50 points): ; ; and for every operation.
Examples
Input
5 3
1 2 100
2 5 100
3 4 100
Output
200
Explanation
The initial array is .
- After adding on : .
- After adding on : .
- After adding on : .
The final maximum is , occurring at positions , so the output is 200.