結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2018-02-09 00:46:36 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 427 bytes |
コンパイル時間 | 2,095 ms |
コンパイル使用メモリ | 74,572 KB |
実行使用メモリ | 58,944 KB |
最終ジャッジ日時 | 2024-10-01 21:02:44 |
合計ジャッジ時間 | 8,689 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 WA * 7 |
ソースコード
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int L = sc.nextInt(); int n = sc.nextInt(); int[] ints = new int[n]; for (int i=0; i<n; i++) { ints[i] = sc.nextInt(); } Arrays.sort(ints); int count = 0; for (int i=0; i<n; i++) { if (L-ints[i] > 0) {count++; L-=ints[i];} else {break;} } System.out.println(count); } }