結果

問題 No.29 パワーアップ
ユーザー hitoyozakehitoyozake
提出日時 2018-08-18 17:03:23
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 688 bytes
コンパイル時間 2,454 ms
コンパイル使用メモリ 146,864 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-06 04:34:35
合計ジャッジ時間 2,457 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `x`
 --> Main.rs:4:9
  |
4 |     let x = std::io::stdin().read_line(& mut buf);
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `i`
  --> Main.rs:14:9
   |
14 |     for i in 0..n{
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`

warning: unused variable: `k`
  --> Main.rs:27:10
   |
27 |     for (k, v) in & hashMap {
   |          ^ help: if this is intentional, prefix it with an underscore: `_k`

warning: variable `hashMap` should have a snake case name
  --> Main.rs:13:13
   |
13 |     let mut hashMap: HashMap<u64, i64> = HashMap::new();
   |             ^^^^^^^ help: convert the identifier to snake case: `hash_map`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: 4 warnings emitted

ソースコード

diff #

fn get_line()->String{
    let mut buf = String::new();
    let x = std::io::stdin().read_line(& mut buf);
    buf
}

use std::collections::HashMap;

fn main() {

    let n = get_line().trim().parse::<u64>().unwrap();
    let mut hashMap: HashMap<u64, i64> = HashMap::new();
    for i in 0..n{
        let s = get_line();
        let items = s.trim().split(' ');

        for item in items{
            let i:u64 = item.parse::<u64>().unwrap();
            *hashMap.entry(i).or_insert(0) += 1;
        }
    }

    let mut sum = 0;
    let mut amari = 0;

    for (k, v) in & hashMap {
        sum += v/2;
        amari += v%2;
    }

    sum += amari / 4;

    println!("{}", sum );

}
0