library_checker/data_structure/
static_range_sum.rs1use competitive::prelude::*;
2#[doc(no_inline)]
3pub use competitive::{algebra::AdditiveOperation, data_structure::Accumulate};
4
5#[verify::library_checker("static_range_sum")]
6pub fn static_range_sum(reader: impl Read, mut writer: impl Write) {
7 let s = read_all_unchecked(reader);
8 let mut scanner = Scanner::new(&s);
9 scan!(scanner, n, q, a: [i64; n], lr: [(usize, usize)]);
10 let acc: Accumulate<AdditiveOperation<i64>> = a.into_iter().collect();
11 for (l, r) in lr.take(q) {
12 writeln!(writer, "{}", acc.fold(l..r)).ok();
13 }
14}