結果

問題 No.5 数字のブロック
コンテスト
ユーザー 🇳🇱🦭🇯🇵
提出日時 2024-09-04 10:53:27
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 5,000 ms
+ 490µs
コード長 824 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 977 ms
コンパイル使用メモリ 188,612 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-25 11:23:48
合計ジャッジ時間 3,137 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io;
use std::io::prelude::*;

fn main() {
    let stdin = io::read_to_string(io::stdin()).unwrap();
    let mut stdin = stdin.split_whitespace();
    let stdout = io::stdout();
    let mut stdout = io::BufWriter::new(stdout.lock());

    let l: usize = stdin.next().unwrap().parse::<usize>().unwrap();
    let n: usize = stdin.next().unwrap().parse::<usize>().unwrap();

    let mut wn: Vec<usize> = vec![198471237812781; 100010];
    for i in 0..n {
        wn[i] = stdin.next().unwrap().parse::<usize>().unwrap();
    }
    
    wn.sort_unstable();

    let sequence: Vec<_> = wn.into_iter().scan(0, |state, x| {
        *state += x;
        if *state > l {
            None
        }
        else {
            Some(*state)
        } 
    }).collect();
    writeln!(stdout, "{}", sequence.len()).unwrap_or(());
}
0