結果

問題 No.5 数字のブロック
ユーザー juger_jvjuger_jv
提出日時 2016-05-03 20:14:56
言語 Java19
(openjdk 21)
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 3,550 ms
コンパイル使用メモリ 71,576 KB
実行使用メモリ 53,028 KB
最終ジャッジ日時 2023-08-11 15:00:39
合計ジャッジ時間 7,117 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,400 KB
testcase_01 AC 44 ms
49,548 KB
testcase_02 AC 43 ms
49,528 KB
testcase_03 AC 76 ms
52,536 KB
testcase_04 AC 64 ms
51,568 KB
testcase_05 AC 87 ms
52,348 KB
testcase_06 AC 70 ms
51,512 KB
testcase_07 AC 67 ms
50,540 KB
testcase_08 AC 71 ms
51,640 KB
testcase_09 AC 56 ms
50,472 KB
testcase_10 AC 87 ms
52,944 KB
testcase_11 AC 66 ms
51,684 KB
testcase_12 AC 76 ms
52,136 KB
testcase_13 AC 90 ms
52,700 KB
testcase_14 AC 46 ms
49,400 KB
testcase_15 AC 46 ms
49,224 KB
testcase_16 AC 85 ms
52,232 KB
testcase_17 AC 91 ms
53,028 KB
testcase_18 AC 93 ms
52,792 KB
testcase_19 AC 92 ms
53,012 KB
testcase_20 AC 44 ms
49,388 KB
testcase_21 AC 44 ms
49,676 KB
testcase_22 AC 43 ms
49,356 KB
testcase_23 AC 44 ms
49,348 KB
testcase_24 AC 47 ms
49,740 KB
testcase_25 AC 54 ms
49,672 KB
testcase_26 AC 45 ms
49,344 KB
testcase_27 AC 45 ms
49,216 KB
testcase_28 AC 43 ms
49,436 KB
testcase_29 AC 63 ms
51,864 KB
testcase_30 AC 56 ms
50,388 KB
testcase_31 AC 43 ms
49,368 KB
testcase_32 AC 43 ms
49,368 KB
testcase_33 AC 43 ms
49,356 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