Skip to content

Commit 2908e2b

Browse files
committed
add abc405c.rs
1 parent 5b308ba commit 2908e2b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/abc/abc405c.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/** THIS IS AN OUTPUT FILE. NOT EDIT THIS FILE DIRECTLY. **/
2+
use proconio::input;
3+
use proconio::marker::*;
4+
use std::marker::PhantomData;
5+
use std::cmp::*;
6+
use std::collections::*;
7+
use itertools::Itertools;
8+
9+
10+
fn main() {
11+
input! {
12+
n:usize,
13+
a:[usize;n]
14+
}
15+
16+
let mut memo = vec![0;n+1];
17+
for i in (0..n).rev() {
18+
memo[i] = memo[i+1] + a[i];
19+
}
20+
21+
let mut result = 0usize;
22+
for i in 0..n-1 {
23+
result += memo[i+1] * a[i];
24+
}
25+
26+
println!("{}", result);
27+
}

0 commit comments

Comments
 (0)