結果

問題 No.5 数字のブロック
ユーザー 水野嶺水野嶺
提出日時 2020-05-20 16:37:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 74,380 KB
実行使用メモリ 59,008 KB
最終ジャッジ日時 2024-04-09 23:00:34
合計ジャッジ時間 11,053 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
52,944 KB
testcase_01 AC 126 ms
54,084 KB
testcase_02 WA -
testcase_03 AC 328 ms
58,520 KB
testcase_04 AC 300 ms
58,472 KB
testcase_05 WA -
testcase_06 AC 322 ms
58,680 KB
testcase_07 AC 305 ms
58,512 KB
testcase_08 AC 331 ms
58,736 KB
testcase_09 AC 220 ms
57,056 KB
testcase_10 AC 393 ms
58,860 KB
testcase_11 AC 294 ms
58,604 KB
testcase_12 AC 340 ms
58,676 KB
testcase_13 AC 375 ms
58,724 KB
testcase_14 AC 140 ms
54,324 KB
testcase_15 WA -
testcase_16 AC 403 ms
59,008 KB
testcase_17 AC 439 ms
58,684 KB
testcase_18 AC 424 ms
58,588 KB
testcase_19 AC 440 ms
58,592 KB
testcase_20 AC 108 ms
52,588 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 121 ms
54,100 KB
testcase_24 AC 149 ms
56,056 KB
testcase_25 AC 183 ms
54,268 KB
testcase_26 AC 122 ms
53,888 KB
testcase_27 AC 122 ms
53,764 KB
testcase_28 AC 124 ms
54,004 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 115 ms
52,984 KB
testcase_32 AC 125 ms
53,920 KB
testcase_33 AC 124 ms
54,132 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