結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
101000010
|
| 提出日時 | 2017-05-17 16:26:54 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 228 ms / 5,000 ms |
| コード長 | 923 bytes |
| コンパイル時間 | 4,427 ms |
| コンパイル使用メモリ | 79,312 KB |
| 実行使用メモリ | 43,912 KB |
| 最終ジャッジ日時 | 2024-11-18 11:09:47 |
| 合計ジャッジ時間 | 10,522 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class No005 {
public static void main(String[] args) {
int BOX_L_SIZE;
int N;
int[] BOX_S;
Scanner sc = new Scanner(System.in);
BOX_L_SIZE = Integer.parseInt(sc.nextLine());
N = Integer.parseInt(sc.nextLine());
BOX_S = new int[N];
String str = sc.nextLine();
String[] inputs = str.split(" ");
for(int i=0; i<N; i++){
BOX_S[i] = Integer.parseInt(inputs[i]);
}
System.out.println(countBox(BOX_L_SIZE, BOX_S));
}
static int countBox(int boxSize, int[] boxS){
int count = 0;
int capaBox = boxSize;
Arrays.sort(boxS);
while(boxS[count] <= capaBox){
capaBox -= boxS[count];
count++;
if(count == boxS.length)break;
}
return count;
}
}
101000010