結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2022-05-12 18:24:55 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 226 ms / 5,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 5,445 ms |
コンパイル使用メモリ | 79,844 KB |
実行使用メモリ | 47,936 KB |
最終ジャッジ日時 | 2024-07-20 12:22:56 |
合計ジャッジ時間 | 9,702 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
import java.util.ArrayList;import java.util.Collections;import java.util.Scanner;public class No5 {public static void main(String[] args) {Scanner s = new Scanner(System.in);ArrayList<Integer> W = new ArrayList<>();int L = Integer.parseInt(s.nextLine()),N = Integer.parseInt(s.nextLine()),i = 0,count = 0;for(i = 0;i < N;i++) {W.add(Integer.parseInt(s.next()));}s.close();i = 0;Collections.sort(W);for(int w : W) {L = L - w;if(L < 0) {break;}else {i++;}}System.out.println(i);}}