結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-02-04 14:45:29 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 251 ms / 5,000 ms |
コード長 | 530 bytes |
コンパイル時間 | 2,376 ms |
コンパイル使用メモリ | 74,256 KB |
実行使用メモリ | 47,820 KB |
最終ジャッジ日時 | 2024-11-18 10:53:07 |
合計ジャッジ時間 | 8,493 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
import java.util.Scanner; import java.util.Arrays; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int sum = 0; int count = 0; int L = scanner.nextInt(); int N = scanner.nextInt(); int a[] = new int[N]; for(int i = 0;i < N;i++){ a[i] = scanner.nextInt(); } Arrays.sort(a); for(int i = 0;i < N;i++){ sum += a[count]; count++; if(sum>L){ break; } } if(sum>L){ count -= 1; } System.out.println(count); scanner.close(); } }