結果

問題 No.2590 100000 Days of Christmas
ユーザー neko_the_shadowneko_the_shadow
提出日時 2024-01-26 12:52:18
言語 Rust
(1.77.0)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 1,458 ms
コンパイル使用メモリ 195,540 KB
実行使用メモリ 12,420 KB
最終ジャッジ日時 2024-01-26 12:52:23
合計ジャッジ時間 4,779 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 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 236 ms
12,420 KB
testcase_07 AC 14 ms
6,676 KB
testcase_08 AC 234 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 1 ms
6,676 KB
testcase_20 AC 233 ms
11,908 KB
testcase_21 AC 218 ms
11,908 KB
testcase_22 AC 212 ms
11,780 KB
testcase_23 AC 234 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_key(|t| t.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