結果

問題 No.2374 ASKT Subsequences
ユーザー とろちゃとろちゃ
提出日時 2023-07-07 23:09:39
言語 Rust
(1.77.0)
結果
AC  
実行時間 1,730 ms / 2,000 ms
コード長 1,605 bytes
コンパイル時間 1,278 ms
コンパイル使用メモリ 142,240 KB
実行使用メモリ 33,372 KB
最終ジャッジ日時 2023-09-29 00:52:30
合計ジャッジ時間 9,567 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 7 ms
6,116 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 13 ms
7,932 KB
testcase_15 AC 21 ms
9,608 KB
testcase_16 AC 9 ms
6,940 KB
testcase_17 AC 37 ms
11,964 KB
testcase_18 AC 112 ms
17,224 KB
testcase_19 AC 89 ms
16,200 KB
testcase_20 AC 250 ms
22,696 KB
testcase_21 AC 352 ms
25,412 KB
testcase_22 AC 188 ms
20,604 KB
testcase_23 AC 113 ms
17,504 KB
testcase_24 AC 111 ms
17,500 KB
testcase_25 AC 96 ms
17,480 KB
testcase_26 AC 816 ms
33,272 KB
testcase_27 AC 725 ms
33,360 KB
testcase_28 AC 417 ms
33,256 KB
testcase_29 AC 1,544 ms
33,372 KB
testcase_30 AC 1,730 ms
33,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![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);
}
0