Skip to content

Commit 98f4faa

Browse files
committed
Add examples/library-checker-static-range-sum.rs
1 parent 58c7a9e commit 98f4faa

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ publish = false
1717
[dev-dependencies]
1818
input = { path = "./crates/input" }
1919
proconio = "=0.3.6"
20+
proconio-derive = "0.2.1"
2021
rand = "0.7.3"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#[macro_use]
2+
extern crate input as _;
3+
#[macro_use]
4+
extern crate proconio_derive as _;
5+
6+
use ac_library_rs::fenwicktree::FenwickTree;
7+
8+
#[allow(clippy::needless_collect)]
9+
#[fastout]
10+
fn main() {
11+
input! {
12+
n: usize,
13+
q: usize,
14+
r#as: [u64; n],
15+
lrs: [(usize, usize); q],
16+
}
17+
18+
let mut fenwick = FenwickTree::new(n, 0);
19+
for (i, a) in r#as.into_iter().enumerate() {
20+
fenwick.add(i, a);
21+
}
22+
for (l, r) in lrs {
23+
println!("{}", fenwick.sum(l, r));
24+
}
25+
}

0 commit comments

Comments
 (0)