結果

問題 No.5 数字のブロック
ユーザー hnthnt
提出日時 2016-03-28 02:09:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 3,611 ms
コンパイル使用メモリ 74,400 KB
実行使用メモリ 58,876 KB
最終ジャッジ日時 2024-04-10 04:16:41
合計ジャッジ時間 12,095 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
53,832 KB
testcase_01 AC 123 ms
54,032 KB
testcase_02 AC 116 ms
54,312 KB
testcase_03 AC 311 ms
58,864 KB
testcase_04 AC 289 ms
58,768 KB
testcase_05 AC 360 ms
58,632 KB
testcase_06 AC 273 ms
57,852 KB
testcase_07 AC 260 ms
58,284 KB
testcase_08 AC 322 ms
58,700 KB
testcase_09 AC 214 ms
56,748 KB
testcase_10 AC 376 ms
58,856 KB
testcase_11 AC 275 ms
58,716 KB
testcase_12 AC 323 ms
58,660 KB
testcase_13 AC 353 ms
58,868 KB
testcase_14 AC 127 ms
54,144 KB
testcase_15 AC 146 ms
53,964 KB
testcase_16 AC 398 ms
58,876 KB
testcase_17 AC 407 ms
58,824 KB
testcase_18 AC 399 ms
58,656 KB
testcase_19 AC 437 ms
58,596 KB
testcase_20 WA -
testcase_21 AC 118 ms
54,108 KB
testcase_22 AC 120 ms
53,912 KB
testcase_23 AC 119 ms
54,028 KB
testcase_24 AC 143 ms
53,972 KB
testcase_25 AC 172 ms
54,464 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 269 ms
58,604 KB
testcase_30 AC 223 ms
56,860 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class no5 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int bigboxL=sc.nextInt();
		int N=sc.nextInt();
		int[] blockarray = new int[N];
		for(int i=0;i<N;i++){
			int blockW=sc.nextInt();
			blockarray[i]=blockW;
		}
		for(int i=0;i<blockarray.length;i++){
			for(int j=i+1;j<blockarray.length;j++){
				if(blockarray[i]>=blockarray[j]){
					int swap=blockarray[i];
					blockarray[i]=blockarray[j];
					blockarray[j]=swap;
				}
			}
		}
		int cnt=0;
		for(int i=0;i<N;i++){
			bigboxL-=blockarray[i];
			if(bigboxL>=0)cnt++;
			if(bigboxL<=0){
				System.out.println(cnt);
				break;
			}else if(bigboxL<0){
				System.out.println(cnt);
				break;
			}

		}
	}
}
0