結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2019-06-16 15:36:30 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,044 bytes |
コンパイル時間 | 4,132 ms |
コンパイル使用メモリ | 75,192 KB |
実行使用メモリ | 48,008 KB |
最終ジャッジ日時 | 2024-11-24 03:45:36 |
合計ジャッジ時間 | 11,976 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 34 |
ソースコード
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc1 = new Scanner(System.in); // Scanner sc2 = new Scanner(System.in); // Scanner sc3 = new Scanner(System.in); List <Integer> W = new ArrayList<Integer>(); //大きな箱の幅 int L = sc1.nextInt(); //ブロックの数 // int N = sc2.nextInt(); int N = sc1.nextInt(); //各ブロックの幅を格納 for(int i=0;i<N;i++ ){ // int input = sc3.nextInt(); int input = sc1.nextInt(); W.add(input); } //昇順でsort Collections.sort(W); //大きな箱の中に、小さい箱を入れていく int total = 0; int kosu = 0; for(int j=0;j<=kosu;j++){ int num = W.get(j); total = total + num; if(total > L){ break; } } System.out.println(kosu); } }