結果
問題 | No.2374 ASKT Subsequences |
ユーザー | haihamabossu |
提出日時 | 2023-07-07 22:52:21 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 2,038 bytes |
コンパイル時間 | 13,692 ms |
コンパイル使用メモリ | 388,724 KB |
実行使用メモリ | 33,792 KB |
最終ジャッジ日時 | 2024-07-21 19:08:08 |
合計ジャッジ時間 | 15,267 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
33,536 KB |
testcase_01 | AC | 25 ms
33,536 KB |
testcase_02 | AC | 25 ms
33,536 KB |
testcase_03 | AC | 25 ms
33,536 KB |
testcase_04 | AC | 25 ms
33,664 KB |
testcase_05 | AC | 25 ms
33,408 KB |
testcase_06 | AC | 25 ms
33,536 KB |
testcase_07 | AC | 25 ms
33,536 KB |
testcase_08 | AC | 25 ms
33,536 KB |
testcase_09 | AC | 26 ms
33,536 KB |
testcase_10 | AC | 26 ms
33,536 KB |
testcase_11 | AC | 26 ms
33,536 KB |
testcase_12 | AC | 26 ms
33,664 KB |
testcase_13 | AC | 26 ms
33,664 KB |
testcase_14 | AC | 27 ms
33,536 KB |
testcase_15 | AC | 28 ms
33,536 KB |
testcase_16 | AC | 27 ms
33,664 KB |
testcase_17 | AC | 30 ms
33,664 KB |
testcase_18 | AC | 34 ms
33,664 KB |
testcase_19 | AC | 33 ms
33,536 KB |
testcase_20 | AC | 39 ms
33,664 KB |
testcase_21 | AC | 41 ms
33,664 KB |
testcase_22 | AC | 36 ms
33,664 KB |
testcase_23 | AC | 33 ms
33,536 KB |
testcase_24 | AC | 33 ms
33,536 KB |
testcase_25 | AC | 28 ms
33,536 KB |
testcase_26 | AC | 50 ms
33,792 KB |
testcase_27 | AC | 28 ms
33,536 KB |
testcase_28 | AC | 36 ms
33,664 KB |
testcase_29 | AC | 54 ms
33,664 KB |
testcase_30 | AC | 35 ms
33,664 KB |
ソースコード
pub mod scanner { pub struct Scanner { buf: Vec<String>, } impl Scanner { pub fn new() -> Self { Self { buf: vec![] } } pub fn new_from(source: &str) -> Self { let source = String::from(source); let buf = Self::split(source); Self { buf } } pub fn next<T: std::str::FromStr>(&mut self) -> T { loop { if let Some(x) = self.buf.pop() { return x.parse().ok().expect(""); } let mut source = String::new(); std::io::stdin().read_line(&mut source).expect(""); self.buf = Self::split(source); } } fn split(source: String) -> Vec<String> { source .split_whitespace() .rev() .map(String::from) .collect::<Vec<_>>() } } } use crate::scanner::Scanner; use std::io::Write; fn main() { let mut scanner = Scanner::new(); let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); let t: usize = 1; for _ in 0..t { solve(&mut scanner, &mut out); } } fn solve(scanner: &mut Scanner, out: &mut std::io::BufWriter<std::io::StdoutLock>) { const MAX: usize = 2000; let n: usize = scanner.next(); let a = (0..n).map(|_| scanner.next::<usize>()).collect::<Vec<_>>(); let mut count = vec![0usize; MAX + 10]; for i in 2..n { count[a[i]] += 1; } let mut dp = vec![vec![0usize; MAX + 10]; MAX + 10]; let mut ans: usize = 0; for i in 1..n - 1 { if a[i] > 10 { let a1 = a[i] - 10; for k in 1..=MAX - a[i] { ans += dp[a1][k] * count[a[i] + k + 1]; } } for j in 0..i { if a[j] + 10 < a[i] { dp[a[j]][a[i] - a[j] - 10] += 1; } } count[a[i + 1]] -= 1; } writeln!(out, "{}", ans).unwrap(); }