Classical Data Structure Problem
Time limit3sMemory limit128 MB
Apply n range updates to an array of length 2^m, where each update adds i to a range and x grows by each new value; output x mod 2^30.
- Level
Hard9 of 10
- Topics
- Segment tree, Array, Simulation
- Solved
- No attempts yet
Problem
You have an integer array of length . Initially, every element is zero.
You also have an integer variable . Initially, .
For each , you are given two integers and , and you perform the following steps:
- Let and .
- Let and .
- For each , increase by , then increase by .
Find the value of at the end of this process.
Input
The first line contains two integers and (; ).
The -th of the following lines contains two integers and ().
Output
Print the value of .
Hint
In the example test, initially and . Then:
- For , and . Then and .
- For , and . Then and .
- For , and . Then and .
- For , and . Then and .
- For , and . Then and .