Sequence and Queries 24
Time limit1sMemory limit512 MB
Maintain an array under point updates and range queries that ask for the largest sum of two distinct elements within a subarray.
- Level
Hard8 of 10
- Topics
- Segment tree, Dynamic programming, Greedy, Implementation
- Solved
- No attempts yet
Problem
A sequence of length is given. Write a program that performs the following queries.
1 i v: change to . (, )2 l r: among all with , print the maximum value. ()
Indices of the sequence start at 1.
Input
The first line gives the size of the sequence . ()
The second line gives . ()
The third line gives the number of queries . ()
Each of the next lines gives one query.
Output
For each type 2 query, print the answer on its own line in order.