結果

問題 No.1198 お菓子配り-1
ユーザー uw_yu1rabbituw_yu1rabbit
提出日時 2020-08-28 22:16:10
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 878 bytes
コンパイル時間 2,908 ms
コンパイル使用メモリ 171,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 13:15:27
合計ジャッジ時間 3,767 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 1 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
6,940 KB
testcase_17 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::collections::*`
 --> main.rs:2:5
  |
2 | use std::collections::*;
  |     ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unnecessary parentheses around `if` condition
  --> main.rs:18:7
   |
18 |     if(s == "1" || s == "2"){
   |       ^                    ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
18 -     if(s == "1" || s == "2"){
18 +     if s == "1" || s == "2" {
   |

warning: variable does not need to be mutable
  --> main.rs:21:13
   |
21 |         let mut n:Vec<char> = s.chars().collect();
   |             ----^
   |             |
   |             help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: 3 warnings emitted

ソースコード

diff #

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let s:String = read();
    if(s == "1" || s == "2"){
        println!("-1");
    }else{
        let mut n:Vec<char> = s.chars().collect();
        let mut dig = vec![0;10];
        for i in n{
          dig[(i as i32 - 48) as usize] += 1;
        }
        let mut k = 0;
        for i in dig{
            k = max(k,i);
        }
        match k{
            1 => println!("1"),
            _ => println!("-1"),
        }
    }
}
0