結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2019-06-24 14:48:47 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 99 ms / 5,000 ms |
コード長 | 883 bytes |
コンパイル時間 | 6,804 ms |
コンパイル使用メモリ | 77,496 KB |
実行使用メモリ | 40,296 KB |
最終ジャッジ日時 | 2024-06-11 15:37:04 |
合計ジャッジ時間 | 7,531 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Tester2 { public static void main(String[] args){ try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){ int l = Integer.parseInt(br.readLine()); int n = Integer.parseInt(br.readLine()); String[] ary = br.readLine().split(" "); int[] b = chgInt(ary); int num=0,cnt=0; for(int i=0; i<b.length; i++) { num += b[i]; if(num<=l) { cnt++; }else { break; } } System.out.println(cnt); }catch(IOException e) { e.printStackTrace(); } } static int[] sort(int[] ary) { Arrays.sort(ary); return ary; } static int[] chgInt(String[] ary) { int[] a = new int[ary.length]; for(int i=0; i<ary.length; i++) { a[i] = Integer.parseInt(ary[i]); } return sort(a); } }