結果

問題 No.2424 Josouzai
ユーザー ずーずるずーずる
提出日時 2023-08-18 21:31:44
言語 Rust
(1.77.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 11,490 ms
コンパイル使用メモリ 377,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 03:24:32
合計ジャッジ時間 13,465 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 8 ms
5,376 KB
testcase_05 AC 25 ms
5,376 KB
testcase_06 AC 25 ms
5,376 KB
testcase_07 AC 24 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 14 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 22 ms
5,376 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 AC 7 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 23 ms
5,376 KB
testcase_21 AC 17 ms
5,376 KB
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 9 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 24 ms
5,376 KB
testcase_26 AC 18 ms
5,376 KB
testcase_27 AC 25 ms
5,376 KB
testcase_28 AC 21 ms
5,376 KB
testcase_29 AC 18 ms
5,376 KB
testcase_30 AC 5 ms
5,376 KB
testcase_31 AC 12 ms
5,376 KB
testcase_32 AC 26 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `read_to_string`
 --> src/main.rs:1:15
  |
1 | use std::io::{read_to_string, self};
  |               ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unnecessary parentheses around `if` condition
  --> src/main.rs:21:12
   |
21 |         if (k>=*i){
   |            ^     ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
21 -         if (k>=*i){
21 +         if k>=*i {
   |

warning: unused variable: `n`
 --> src/main.rs:9:9
  |
9 |     let n:u32=tmp.next().unwrap();
  |         ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

use std::io::{read_to_string, self};

fn main() {

    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let  mut tmp= x.split_whitespace().map(|a|a.parse::<u32>().unwrap() );

    let n:u32=tmp.next().unwrap();
    let mut k:u32=tmp.next().unwrap();
    // println!("aaa");
    x.clear();
    io::stdin().read_line(&mut x).unwrap();

    let v=x.split_whitespace().map(|x|x.parse::<u32>().unwrap());
    let mut a=v.collect::<Vec<u32>>();
    a.sort_by(|a, b| a.partial_cmp(b).unwrap());
    // a.iter().for_each(|f|print!("{} ",f));
    let mut count=0;
    for i in a.iter(){
        if (k>=*i){
            k-=i;
            count+=1;
        }else{
            break;
        }
    }
    print!("{} {}",count, k);
}
0