結果

問題 No.2590 100000 Days of Christmas
ユーザー neko_the_shadowneko_the_shadow
提出日時 2024-01-26 12:49:41
言語 Rust
(1.77.0)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 195,104 KB
実行使用メモリ 12,420 KB
最終ジャッジ日時 2024-01-26 12:50:00
合計ジャッジ時間 6,379 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 261 ms
12,420 KB
testcase_07 AC 15 ms
6,676 KB
testcase_08 AC 276 ms
11,908 KB
testcase_09 AC 15 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 0 ms
6,676 KB
testcase_20 AC 298 ms
11,908 KB
testcase_21 AC 278 ms
11,908 KB
testcase_22 AC 278 ms
11,780 KB
testcase_23 AC 297 ms
11,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::{collections::HashMap, io};

fn main() {
    let mut map = HashMap::new();

    let n = read_line().parse::<i128>().unwrap();
    for i in 0..n {
        let s = read_line();
        *map.entry(s).or_insert(0) += (i + 1) * (n - i);
    }

    let mut entries = map.iter().collect::<Vec<_>>();
    entries.sort_by(|t1, t2| t1.0.cmp(&t2.0));
    for (k, v) in entries {
        println!("{} {}", v, k)
    }
}

fn read_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line.trim_end().to_string()
}
0