結果

問題 No.2424 Josouzai
ユーザー ずーずる
提出日時 2023-08-18 21:31:44
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 14,278 ms
コンパイル使用メモリ 375,440 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 05:48:56
合計ジャッジ時間 16,117 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
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