結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-02-17 20:06:54 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 3,312 ms |
コンパイル使用メモリ | 74,756 KB |
実行使用メモリ | 53,184 KB |
最終ジャッジ日時 | 2024-09-22 07:31:16 |
合計ジャッジ時間 | 6,794 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 14 |
ソースコード
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package yukicoder001_100; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; /** * * @author yuya */ public class No005 { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line1 = br.readLine(); String line2 = br.readLine(); String line3 = br.readLine(); int L = Integer.parseInt(line1); int N = Integer.parseInt(line2); String [] s = line3.split(" ",0); int n[] = new int[N]; for(int i=0;i<s.length;i++){ n[i]=Integer.parseInt(s[i]); } Arrays.sort(n); int ans=0; int b =0; for(int i=0;i<n.length;i++){ if(b<L){ b+=n[i]; ans++; }else{ break; } } System.out.println(ans-1); } }