結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-02-05 10:23:17 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 632 bytes |
コンパイル時間 | 3,783 ms |
コンパイル使用メモリ | 74,612 KB |
実行使用メモリ | 47,588 KB |
最終ジャッジ日時 | 2024-07-06 14:18:22 |
合計ジャッジ時間 | 12,212 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 RE * 10 |
ソースコード
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;sum <= L;count++) { sum += W[count]; } System.out.println(count - 1); } }