結果

問題 No.5 数字のブロック
ユーザー kazapyon27kazapyon27
提出日時 2017-05-07 17:06:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 3,495 ms
コンパイル使用メモリ 72,436 KB
実行使用メモリ 61,132 KB
最終ジャッジ日時 2023-10-12 16:10:36
合計ジャッジ時間 10,606 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,632 KB
testcase_01 AC 123 ms
55,764 KB
testcase_02 AC 124 ms
55,812 KB
testcase_03 AC 222 ms
59,648 KB
testcase_04 AC 208 ms
59,160 KB
testcase_05 AC 233 ms
60,660 KB
testcase_06 AC 217 ms
59,168 KB
testcase_07 AC 210 ms
59,180 KB
testcase_08 AC 216 ms
58,428 KB
testcase_09 AC 191 ms
58,108 KB
testcase_10 AC 236 ms
59,244 KB
testcase_11 AC 209 ms
59,108 KB
testcase_12 AC 220 ms
59,924 KB
testcase_13 AC 227 ms
58,896 KB
testcase_14 AC 134 ms
55,624 KB
testcase_15 AC 157 ms
55,984 KB
testcase_16 AC 237 ms
61,132 KB
testcase_17 AC 240 ms
59,464 KB
testcase_18 AC 240 ms
59,420 KB
testcase_19 AC 243 ms
59,856 KB
testcase_20 WA -
testcase_21 AC 121 ms
55,932 KB
testcase_22 AC 121 ms
55,876 KB
testcase_23 AC 121 ms
56,120 KB
testcase_24 AC 147 ms
55,876 KB
testcase_25 AC 177 ms
56,428 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 211 ms
59,128 KB
testcase_30 AC 195 ms
58,756 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*No.5 数字のブロック*/
import java.util.*;
public class No5 {
	public static void main(String[] args) {
		short box_width,block_quantity,count;		
		try(Scanner input = new Scanner(System.in)){
			box_width=input.nextShort();
			block_quantity=input.nextShort();
			short block_width[]= new short[block_quantity];
			for(int i=0;i<block_quantity;i++){
				block_width[i]=input.nextShort();
			}
			Arrays.sort(block_width);
			for(count=1;count<=block_quantity;count++){
				box_width-=block_width[count-1];
				if(box_width==0){
					break;
				}else if(box_width<0){
					count-=1;
					break;
				}
			}
			System.out.println(count);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
0