結果

問題 No.5 数字のブロック
ユーザー Mcpu3Mcpu3
提出日時 2018-06-22 00:30:43
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 525 bytes
コンパイル時間 2,614 ms
コンパイル使用メモリ 71,612 KB
実行使用メモリ 60,680 KB
最終ジャッジ日時 2023-09-13 07:47:21
合計ジャッジ時間 12,376 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,200 KB
testcase_01 AC 123 ms
55,768 KB
testcase_02 RE -
testcase_03 AC 347 ms
60,420 KB
testcase_04 AC 308 ms
60,272 KB
testcase_05 AC 402 ms
60,088 KB
testcase_06 AC 328 ms
59,932 KB
testcase_07 AC 310 ms
60,348 KB
testcase_08 AC 346 ms
60,120 KB
testcase_09 AC 240 ms
58,872 KB
testcase_10 AC 429 ms
60,036 KB
testcase_11 AC 288 ms
60,296 KB
testcase_12 AC 349 ms
60,164 KB
testcase_13 AC 398 ms
60,320 KB
testcase_14 AC 136 ms
55,904 KB
testcase_15 AC 150 ms
55,776 KB
testcase_16 AC 418 ms
60,328 KB
testcase_17 AC 471 ms
60,040 KB
testcase_18 AC 441 ms
60,400 KB
testcase_19 AC 492 ms
60,680 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 123 ms
55,628 KB
testcase_24 AC 150 ms
56,144 KB
testcase_25 AC 190 ms
56,192 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 295 ms
59,920 KB
testcase_30 AC 224 ms
59,528 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class no5{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int l,n,a=0,i,j,t,s=0,w[]=new int[10000];
		l=stdIn.nextInt();
		n=stdIn.nextInt();
		for(i=0;i<n;i++) {
			w[i]=stdIn.nextInt();
			s+=w[i];
		}
		for(i=0;i<n-1;i++) {
			for(j=n-1;j>i;j--) {
				if(w[j-1]>w[j]) {
					t=w[j-1];
					w[j-1]=w[j];
					w[j]=t;
				}
			}
		}
		for(i=0;;i++) if(l<(a+=w[i])) break;
		if(l<s) System.out.print(i);
		else System.out.print(n);
	}
}
0