結果

問題 No.5 数字のブロック
ユーザー 水野嶺水野嶺
提出日時 2020-05-20 16:40:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 439 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 74,612 KB
実行使用メモリ 58,868 KB
最終ジャッジ日時 2024-04-09 23:01:05
合計ジャッジ時間 10,793 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
52,716 KB
testcase_01 AC 107 ms
52,968 KB
testcase_02 AC 107 ms
52,952 KB
testcase_03 AC 326 ms
58,708 KB
testcase_04 AC 289 ms
58,680 KB
testcase_05 AC 334 ms
57,916 KB
testcase_06 AC 300 ms
58,868 KB
testcase_07 AC 248 ms
57,864 KB
testcase_08 AC 310 ms
58,800 KB
testcase_09 AC 219 ms
56,832 KB
testcase_10 AC 378 ms
58,800 KB
testcase_11 AC 283 ms
58,848 KB
testcase_12 AC 327 ms
58,712 KB
testcase_13 AC 343 ms
58,772 KB
testcase_14 AC 132 ms
54,192 KB
testcase_15 AC 145 ms
54,524 KB
testcase_16 AC 359 ms
58,820 KB
testcase_17 AC 385 ms
58,772 KB
testcase_18 AC 366 ms
58,164 KB
testcase_19 AC 439 ms
58,848 KB
testcase_20 AC 123 ms
54,104 KB
testcase_21 AC 110 ms
52,984 KB
testcase_22 AC 115 ms
52,956 KB
testcase_23 AC 115 ms
53,120 KB
testcase_24 AC 150 ms
54,104 KB
testcase_25 AC 178 ms
54,656 KB
testcase_26 AC 107 ms
52,732 KB
testcase_27 AC 117 ms
54,084 KB
testcase_28 AC 117 ms
54,060 KB
testcase_29 AC 288 ms
58,528 KB
testcase_30 AC 220 ms
56,700 KB
testcase_31 AC 116 ms
53,924 KB
testcase_32 AC 121 ms
54,004 KB
testcase_33 AC 105 ms
52,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) 
	{
		// 入力値の読み込み
		Scanner sc = new Scanner(System.in);
		int  k = sc.nextInt();
		int  n = sc.nextInt();
		int count=0;
		int[]  a = new int[n];
		
		// 配列の挿入
		for(int m=0;m < n;m++){
		a[m] = sc.nextInt();
		}
		
		// ソート
		for(int i=0;i<a.length-1;i++){
			
		// 下から上に順番に比較します
		for(int j=a.length-1;j>i;j--){
		
		// 上の方が大きいときは互いに入れ替えます
		if(a[j]<a[j-1]){
		int t=a[j];
		a[j]=a[j-1];
		a[j-1]=t;
		}
		}
		}
		
		for(int m=0;m < n;m++){
		if(k >= a[m]){
		k -= a[m];
		count += 1;
		}else{
		break;
		}
		}
		
		System.out.println(count);
	}
}
0