結果

問題 No.5 数字のブロック
ユーザー juger_jvjuger_jv
提出日時 2016-05-03 20:14:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 74,380 KB
実行使用メモリ 40,364 KB
最終ジャッジ日時 2024-04-29 07:12:28
合計ジャッジ時間 5,467 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
36,792 KB
testcase_01 AC 51 ms
37,088 KB
testcase_02 AC 53 ms
37,084 KB
testcase_03 AC 93 ms
38,472 KB
testcase_04 AC 76 ms
38,360 KB
testcase_05 AC 102 ms
39,628 KB
testcase_06 AC 87 ms
38,880 KB
testcase_07 AC 74 ms
38,244 KB
testcase_08 AC 83 ms
38,352 KB
testcase_09 AC 61 ms
37,144 KB
testcase_10 AC 94 ms
39,976 KB
testcase_11 AC 79 ms
38,196 KB
testcase_12 AC 86 ms
38,600 KB
testcase_13 AC 101 ms
39,592 KB
testcase_14 AC 51 ms
37,044 KB
testcase_15 AC 52 ms
36,984 KB
testcase_16 AC 92 ms
39,112 KB
testcase_17 AC 103 ms
39,512 KB
testcase_18 AC 104 ms
39,416 KB
testcase_19 AC 107 ms
40,364 KB
testcase_20 AC 52 ms
36,964 KB
testcase_21 AC 51 ms
36,848 KB
testcase_22 AC 52 ms
36,980 KB
testcase_23 AC 51 ms
36,664 KB
testcase_24 AC 52 ms
37,152 KB
testcase_25 AC 54 ms
36,972 KB
testcase_26 AC 52 ms
36,912 KB
testcase_27 AC 55 ms
36,984 KB
testcase_28 AC 52 ms
36,980 KB
testcase_29 AC 78 ms
38,292 KB
testcase_30 AC 61 ms
37,384 KB
testcase_31 AC 50 ms
36,988 KB
testcase_32 AC 52 ms
36,688 KB
testcase_33 AC 51 ms
36,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
class no5
{
    public static void main(String args[])throws IOException
    {
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	int l=Integer.parseInt(sc.readLine());
	int n=Integer.parseInt(sc.readLine());
	String w[]=sc.readLine().split(" ");
	int wi[]=new int[n];
	for(int i=0;i<n;i++)wi[i]=Integer.parseInt(w[i]);
	Arrays.sort(wi);
	int ans=0,s=l,i=0;
	do
	    {
		if(s>=wi[i])
		    {
		    s-=wi[i];
		    ans++;
		    }
		else break;
		//System.out.println(s);
		i++;
	    }while(s>=0&&i<n);
	System.out.println(ans);
    }
}
0