結果

問題 No.318 学学学学学
ユーザー tabataba
提出日時 2024-07-31 14:34:43
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 841 bytes
コンパイル時間 12,875 ms
コンパイル使用メモリ 386,500 KB
実行使用メモリ 12,700 KB
最終ジャッジ日時 2024-07-31 14:35:01
合計ジャッジ時間 17,813 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
12,568 KB
testcase_01 AC 5 ms
6,812 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 4 ms
6,944 KB
testcase_04 AC 5 ms
6,940 KB
testcase_05 AC 23 ms
10,820 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `HashMap`, `HashSet`, `VecDeque`, `fmt::Debug`, `io::stdin`, `str::FromStr`, `sync::OnceLock`
 --> src/main.rs:2:29
  |
2 |     collections::{BTreeSet, HashMap, HashSet, VecDeque},
  |                             ^^^^^^^  ^^^^^^^  ^^^^^^^^
3 |     fmt::Debug,
  |     ^^^^^^^^^^
4 |     io::stdin,
  |     ^^^^^^^^^
5 |     str::FromStr,
  |     ^^^^^^^^^^^^
6 |     sync::OnceLock,
  |     ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `proconio::marker::Chars`
 --> src/main.rs:9:5
  |
9 | use proconio::marker::Chars;
  |     ^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

use std::{
    collections::{BTreeSet, HashMap, HashSet, VecDeque},
    fmt::Debug,
    io::stdin,
    str::FromStr,
    sync::OnceLock,
};

use proconio::marker::Chars;

fn main() {
    proconio::input! {
        n: u64,
        a: [u64; n],
    }
    let mut s = a.clone();
    s.sort_unstable();
    let s = s
        .windows(2)
        .filter(|s| s[0] == s[1])
        .map(|s| s[0])
        .collect::<BTreeSet<u64>>();
    let mut r = a.clone();
    for s in s {
        let first = a.iter().position(|a| *a == s).unwrap();
        let last = a.iter().rposition(|a| *a == s).unwrap();
        for i in first..=last {
            r[i] = std::cmp::max(r[i], s);
        }
    }
    println!(
        "{}",
        r.into_iter()
            .map(|r| format!("{r}"))
            .collect::<Vec<String>>()
            .join(" ")
    );
}
0