結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-24 15:47:48 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 705 bytes |
| コンパイル時間 | 11,001 ms |
| コンパイル使用メモリ | 389,856 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 08:55:18 |
| 合計ジャッジ時間 | 12,075 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
fn run(args: &Vec<String>) -> Vec<String> {
let l: u32 = args[0].parse().unwrap();
//let n: u32 = args[0].parse().unwrap();
let mut ws: Vec<u32> = args[2].split(' ').map(|s| s.parse().unwrap()).collect();
ws.sort();
let mut s = 0;
let mut c = 0;
for w in ws {
s += w;
if s > l {
break;
}
c += 1
}
vec![c.to_string()]
}
fn main() {
let args = lines(BufReader::new(io::stdin()));
for line in run(&args) {
println!("{}", line);
}
}
fn lines<R: Read>(reader: BufReader<R>) -> Vec<String> {
reader.lines().map(|l| l.unwrap()).collect()
}