結果
問題 |
No.2374 ASKT Subsequences
|
ユーザー |
![]() |
提出日時 | 2023-07-07 23:09:39 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1,773 ms / 2,000 ms |
コード長 | 1,605 bytes |
コンパイル時間 | 13,523 ms |
コンパイル使用メモリ | 376,784 KB |
実行使用メモリ | 33,280 KB |
最終ジャッジ日時 | 2024-07-21 19:32:47 |
合計ジャッジ時間 | 20,623 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#![allow(non_snake_case)] #![allow(unused_imports)] #![allow(unused_macros)] #![allow(clippy::needless_range_loop)] #![allow(clippy::comparison_chain)] #![allow(clippy::nonminimal_bool)] #![allow(clippy::neg_multiply)] #![allow(dead_code)] // use itertools::Itertools; // use std::collections::{BTreeSet, HashSet, VecDeque}; // use std::f64::consts::PI; // use proconio::fastout; // use proconio::*; // use std::cmp::{max, min}; use std::io::{self, BufRead}; // #[fastout] fn main() { let stdin = io::stdin(); let mut lines = stdin.lock().lines(); // Nをusizeとして読み込む let n: usize = lines.next().unwrap().unwrap().parse().unwrap(); // A1からANまでを読み込んでベクターに格納 let a: Vec<usize> = lines .next() .unwrap() .unwrap() .split_whitespace() .map(|s| s.parse().unwrap()) .collect(); let mut countList: Vec<Vec<usize>> = vec![vec![0; 2001]; n]; for i in (0..n).rev() { for j in 0..2001 { if i < n - 1 { countList[i][j] = countList[i + 1][j]; } } countList[i][a[i]] += 1; } let mut ans = 0; for i in 0..n { for j in i + 1..n { if (a[j] as i128) - (a[i] as i128) - 10 <= 0 { continue; } let diff = a[j] - a[i] - 10; for k in j + 1..n { if (a[k] == a[j] - diff) && (a[k] + diff + 1 < 2001) { ans += countList[k][a[k] + diff + 1]; } } } } println!("{}", ans); }