結果

問題 No.5 数字のブロック
ユーザー history_Basshistory_Bass
提出日時 2017-02-28 22:50:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 223 ms / 5,000 ms
コード長 855 bytes
コンパイル時間 3,565 ms
コンパイル使用メモリ 77,708 KB
実行使用メモリ 59,872 KB
最終ジャッジ日時 2023-08-11 17:07:18
合計ジャッジ時間 10,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,528 KB
testcase_01 AC 125 ms
55,832 KB
testcase_02 AC 126 ms
56,080 KB
testcase_03 AC 203 ms
57,420 KB
testcase_04 AC 179 ms
55,548 KB
testcase_05 AC 212 ms
57,756 KB
testcase_06 AC 201 ms
57,284 KB
testcase_07 AC 196 ms
57,152 KB
testcase_08 AC 202 ms
56,892 KB
testcase_09 AC 165 ms
55,884 KB
testcase_10 AC 216 ms
57,284 KB
testcase_11 AC 197 ms
57,356 KB
testcase_12 AC 203 ms
57,720 KB
testcase_13 AC 214 ms
57,520 KB
testcase_14 AC 130 ms
55,868 KB
testcase_15 AC 130 ms
55,880 KB
testcase_16 AC 212 ms
57,316 KB
testcase_17 AC 223 ms
57,764 KB
testcase_18 AC 219 ms
57,724 KB
testcase_19 AC 220 ms
59,872 KB
testcase_20 AC 124 ms
55,804 KB
testcase_21 AC 124 ms
55,560 KB
testcase_22 AC 124 ms
55,676 KB
testcase_23 AC 126 ms
55,800 KB
testcase_24 AC 134 ms
55,812 KB
testcase_25 AC 144 ms
55,664 KB
testcase_26 AC 127 ms
55,920 KB
testcase_27 AC 126 ms
55,976 KB
testcase_28 AC 127 ms
55,804 KB
testcase_29 AC 179 ms
55,900 KB
testcase_30 AC 166 ms
55,620 KB
testcase_31 AC 125 ms
55,888 KB
testcase_32 AC 126 ms
55,820 KB
testcase_33 AC 124 ms
55,520 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