提出 #60059565


ソースコード 拡げる

use proconio::marker::Usize1;

fn main() {
    proconio::input! {
        n: usize,
        xs: [Usize1; n],
    }
    let f = |s| {
        let mut res = 0;
        let mut l = s - 2;
        let mut cnt = vec![0; n];
        let mut ovf = 0;
        for r in (s..=n).step_by(2) {
            cnt[xs[r - 1]] += 1;
            if cnt[xs[r - 1]] == 2 {
                ovf += 1;
            }
            while r > l {
                if xs[r - 1] != xs[r - 2] || ovf > 0 {
                    l += 2;
                    cnt[xs[l - 1]] -= 1;
                    if cnt[xs[l - 1]] == 1 {
                        ovf -= 1;
                    }
                } else {
                    break;
                }
            }
            res = res.max(r - l);
        }
        res
    };
    let res = f(2).max(f(3));
    println!("{res}");
}

提出情報

提出日時
問題 D - 1122 Substring
ユーザ nishinoyama
言語 Rust (rustc 1.70.0)
得点 425
コード長 880 Byte
結果 AC
実行時間 8 ms
メモリ 5424 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 3
AC × 39
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 1928 KiB
example_01.txt AC 0 ms 1900 KiB
example_02.txt AC 1 ms 1972 KiB
hand_00.txt AC 7 ms 5328 KiB
hand_01.txt AC 8 ms 5356 KiB
hand_02.txt AC 8 ms 5272 KiB
hand_03.txt AC 8 ms 5280 KiB
hand_04.txt AC 6 ms 4780 KiB
hand_05.txt AC 1 ms 1924 KiB
random_00.txt AC 7 ms 4804 KiB
random_01.txt AC 8 ms 4732 KiB
random_02.txt AC 7 ms 4844 KiB
random_03.txt AC 7 ms 5144 KiB
random_04.txt AC 7 ms 5312 KiB
random_05.txt AC 7 ms 5252 KiB
random_06.txt AC 7 ms 5424 KiB
random_07.txt AC 7 ms 5408 KiB
random_08.txt AC 7 ms 5348 KiB
random_09.txt AC 8 ms 5368 KiB
random_10.txt AC 7 ms 4780 KiB
random_11.txt AC 8 ms 4904 KiB
random_12.txt AC 7 ms 4644 KiB
random_13.txt AC 7 ms 5072 KiB
random_14.txt AC 7 ms 5420 KiB
random_15.txt AC 7 ms 5408 KiB
random_16.txt AC 7 ms 5220 KiB
random_17.txt AC 7 ms 5328 KiB
random_18.txt AC 7 ms 5284 KiB
random_19.txt AC 7 ms 5344 KiB
random_20.txt AC 8 ms 5352 KiB
random_21.txt AC 8 ms 5368 KiB
random_22.txt AC 8 ms 5224 KiB
random_23.txt AC 8 ms 5372 KiB
random_24.txt AC 7 ms 5344 KiB
random_25.txt AC 7 ms 5344 KiB
random_26.txt AC 7 ms 5216 KiB
random_27.txt AC 7 ms 5316 KiB
random_28.txt AC 8 ms 5296 KiB
random_29.txt AC 8 ms 5404 KiB