結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
aaaaasatori
|
| 提出日時 | 2018-02-05 10:42:16 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 320 ms / 5,000 ms |
| コード長 | 663 bytes |
| 記録 | |
| コンパイル時間 | 2,383 ms |
| コンパイル使用メモリ | 82,248 KB |
| 実行使用メモリ | 50,272 KB |
| 最終ジャッジ日時 | 2026-05-12 23:57:23 |
| 合計ジャッジ時間 | 8,862 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.Scanner;
public class No5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int L = sc.nextInt(); //箱の幅
int N = sc.nextInt(); //ブロックの数
int W[] = new int[N]; //各ブロックの幅
int x;
int sum = 0;
int count;
for(int i = 0;i < N;i++) {
W[i] = sc.nextInt();
}
for(int i = 0;i < N;i++) { //Wを昇順にソート
for(int j = i + 1;j < N;j++) {
if(W[i] > W[j]) {
x = W[i];
W[i] = W[j];
W[j] = x;
}
}
}
for(count = 0;count < N;count++) {
sum += W[count];
if(sum > L) {
break;
}
}
System.out.println(count);
}
}
aaaaasatori