結果

問題 No.5 数字のブロック
ユーザー iicafiaxusiicafiaxus
提出日時 2016-08-29 21:57:32
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 417 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 130,268 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 03:49:38
合計ジャッジ時間 1,833 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int l = readln.chomp.to!int;
	int n = readln.chomp.to!int;
	int[] ws = readln.chomp.split.map!(to!int).array;
	
	ws.sort!("a < b")();
	
	int sum = 0;
	int ans = 0;
	foreach(w; ws){
		if(sum + w <= l) sum += w, ans += 1;
		else break;
		}
	
	ans.writeln;
	}
0