We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 87ebb12 commit b4b67b5Copy full SHA for b4b67b5
src/abc/abc417c.rs
@@ -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