PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000025. Tổng đoạn có cập nhật (Range Sum Query - Mutable)
HỌC THEO LỘ TRÌNH
3 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng đoạn có cập nhật (Range Sum Query - Mutable)
Range Sum Query - Mutable
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of integers. Process operations in their given order. U i x sets the element at index to . S l r asks for the current sum . Array indices are zero-based.
Input
The first line contains . The next line contains integers . Each of the following lines has the form U i x or S l r.
Output
For every S operation, print the current inclusive range sum on a separate line.
Subtasks
- Subtask 1 (20 points): ; ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; ; .
Examples
Input
3 3
1 3 5
S 0 2
U 1 2
S 0 2
Output
9
8
Explanation
The original sum is 9. After updating index 1 to 2, the sum becomes 8.