Skip to content

Commit b4b67b5

Browse files
committed
add abc417c.rs
1 parent 87ebb12 commit b4b67b5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/abc/abc417c.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
8+
fn main() {
9+
input! {
10+
n:usize,
11+
a:[isize;n]
12+
}
13+
14+
let mut map1 = HashMap::new();
15+
let mut map2 = HashMap::new();
16+
for i in 0..n {
17+
let ai = i as isize + 1;
18+
19+
*map1.entry((ai-a[i])).or_insert(0) += 1;
20+
*map2.entry((ai+a[i])).or_insert(0) += 1;
21+
}
22+
23+
let mut result = 0usize;
24+
for (x, num) in map1.iter() {
25+
if let Some(&num2) = map2.get(x) {
26+
result += num * num2;
27+
}
28+
}
29+
30+
println!("{}", result);
31+
}

0 commit comments

Comments
 (0)