Skip to content

Commit

Permalink
past202212-open g
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 15, 2023
1 parent a0a9715 commit c8cb881
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cargo-atcoder-1.70.0/contests/past202212-open/src/bin/g.rs
@@ -1,10 +1,24 @@
use proconio::{input, marker::Usize1};
use proconio::input;

fn main() {
input! {
n: usize,
a: [Usize1; n],
a: [i64; n],
};
let ans = n - a.len();
let s = std::iter::once(0)
.chain(a.iter().scan(0, |acc, &i| {
*acc += i;
Some(*acc)
}))
.collect::<Vec<i64>>();

let mut max = a[0];
let mut min = s[0];
for s_i in s.iter().copied().skip(1) {
max = max.max(s_i - min);
min = min.min(s_i);
}

let ans = max;
println!("{}", ans);
}

0 comments on commit c8cb881

Please sign in to comment.