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

980 B

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.

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).

Difference Array

Consider the array formed by a_i-a_{i-1}.

Prefix Minimum, Etc.

Using