結果

問題 No.5 数字のブロック
ユーザー history_Basshistory_Bass
提出日時 2017-02-28 22:50:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 215 ms / 5,000 ms
コード長 855 bytes
コンパイル時間 3,579 ms
コンパイル使用メモリ 77,992 KB
実行使用メモリ 43,372 KB
最終ジャッジ日時 2024-04-29 08:50:30
合計ジャッジ時間 10,234 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
39,844 KB
testcase_01 AC 127 ms
41,224 KB
testcase_02 AC 125 ms
41,424 KB
testcase_03 AC 180 ms
42,520 KB
testcase_04 AC 179 ms
41,808 KB
testcase_05 AC 207 ms
43,156 KB
testcase_06 AC 193 ms
42,288 KB
testcase_07 AC 186 ms
42,032 KB
testcase_08 AC 192 ms
42,264 KB
testcase_09 AC 170 ms
41,688 KB
testcase_10 AC 201 ms
43,140 KB
testcase_11 AC 170 ms
41,836 KB
testcase_12 AC 187 ms
42,384 KB
testcase_13 AC 203 ms
43,132 KB
testcase_14 AC 133 ms
41,216 KB
testcase_15 AC 121 ms
40,064 KB
testcase_16 AC 202 ms
43,036 KB
testcase_17 AC 208 ms
43,372 KB
testcase_18 AC 204 ms
43,324 KB
testcase_19 AC 215 ms
43,360 KB
testcase_20 AC 126 ms
41,036 KB
testcase_21 AC 129 ms
41,328 KB
testcase_22 AC 110 ms
40,088 KB
testcase_23 AC 123 ms
41,200 KB
testcase_24 AC 133 ms
41,692 KB
testcase_25 AC 142 ms
41,208 KB
testcase_26 AC 125 ms
41,244 KB
testcase_27 AC 110 ms
40,104 KB
testcase_28 AC 112 ms
39,960 KB
testcase_29 AC 174 ms
41,772 KB
testcase_30 AC 172 ms
41,392 KB
testcase_31 AC 116 ms
40,220 KB
testcase_32 AC 112 ms
39,848 KB
testcase_33 AC 112 ms
39,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

public class block {
	protected static String wide[];
	protected static int[] wideN;
	public static void main(String args[]){
		//文字の読み込み
		Scanner sc=new Scanner(System.in);
		String[] line=new String[3];
		line[0]=sc.nextLine();
		line[1]=sc.nextLine();
		line[2]=sc.nextLine();
		//文字を数値に変換
		int[] n=new int[3];
		n[0]=Integer.parseInt(line[0]);
		n[1]=Integer.parseInt(line[1]);
		
		wide=line[2].split(" ",0);
		
		wideN=new int[wide.length];
		int m=0;
		while(m<wide.length){
			wideN[m]=Integer.parseInt(wide[m]);
			m++;
		}
		
		Arrays.sort(wideN);//配列を昇順に並べる
		
		int count=0,rent=n[0];
		for(int i=0;i<n[1];i++){
			if(rent-wideN[i]>=0){
				rent=rent-wideN[i];
				count++;
			}else{
				break;
			}
		}
		
		System.out.println(count);
	}
}
0