Skip to content

Commit

Permalink
tessoku-book/c03
Browse files Browse the repository at this point in the history
  • Loading branch information
emanon001 committed Jan 9, 2023
1 parent 187863e commit 40c99d8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tessoku-book/src/bin/c03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,29 @@ use std::collections::*;

fn solve() {
input! {
d: usize,
av: [i64; d],
q: usize,
stv: [(Usize1, Usize1); q]
};

let cusum = av
.into_iter()
.scan(0, |state, x| {
*state += x;
Some(*state)
})
.collect::<Vec<_>>();
for (s, t) in stv {
let res = if cusum[s] > cusum[t] {
(s + 1).to_string()
} else if cusum[t] > cusum[s] {
(t + 1).to_string()
} else {
"Same".to_string()
};
println!("{}", res);
}
}

fn main() {
Expand Down

0 comments on commit 40c99d8

Please sign in to comment.