This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/Silver/Silver_Psum.md
2020-06-03 16:01:52 -04:00

27 lines
980 B
Markdown

# Silver - Prefix Sums
(started by eric wei; not done)
## The Task
Given an array of size $N$, answer $Q$ queries of the following form: Find the sum of all elements between indices $i$ and $j$.
* [CSES Range Sum Queries I](https://cses.fi/problemset/task/1646)
## Tutorials
(This technique is also known as *cumulative sum* or *partial sums*.)
See Ch 11 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
- CPH 9.1
- aka Cumulative Sum, Partial Sums
- 2D
## Extensions
### 2D Prefix Sums
Given a 2-Dimension array of size $NxM$, answer $Q$ queries of the following form: Find the sum of all elements within the rectangle of indices $(x1,y1)$ to $(x2,y2)$.
* [CSES Forest Queries](https://cses.fi/problemset/task/1652)
### Difference Array
Consider the array formed by $a_i-a_{i-1}$.
* [USACO Painting the Barn](http://www.usaco.org/index.php?page=viewproblem2&cpid=919) (i should find an easier one because this is hard)
### Prefix Minimum, Etc.
Using