結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2020-09-17 21:13:10 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 531 bytes |
コンパイル時間 | 3,986 ms |
コンパイル使用メモリ | 76,200 KB |
実行使用メモリ | 59,092 KB |
最終ジャッジ日時 | 2024-06-22 06:50:32 |
合計ジャッジ時間 | 9,654 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 7 RE * 7 |
ソースコード
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int c = sc.nextInt(); int h = sc.nextInt(); List<Integer> a = new ArrayList<>(); for(int i=0;i<h;i++) { int x = sc.nextInt(); a.add(x); } Collections.sort(a); int sum =0; int cnt=0; int g=0; while(sum<c) { sum+=a.get(g); if(sum<c) { cnt++; } g++; } System.out.println(cnt); } }