結果

問題 No.5 数字のブロック
コンテスト
ユーザー 🇳🇱🦭🇯🇵
提出日時 2024-09-04 10:53:27
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 824 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,237 ms
コンパイル使用メモリ 193,700 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 00:12:24
合計ジャッジ時間 2,705 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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