結果
問題 | No.5 数字のブロック |
ユーザー | juger_jv |
提出日時 | 2016-05-03 20:14:56 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 108 ms / 5,000 ms |
コード長 | 596 bytes |
コンパイル時間 | 2,203 ms |
コンパイル使用メモリ | 75,504 KB |
実行使用メモリ | 52,668 KB |
最終ジャッジ日時 | 2024-11-18 08:33:04 |
合計ジャッジ時間 | 5,585 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
import java.util.*; import java.io.*; class no5 { public static void main(String args[])throws IOException { BufferedReader sc=new BufferedReader(new InputStreamReader(System.in)); int l=Integer.parseInt(sc.readLine()); int n=Integer.parseInt(sc.readLine()); String w[]=sc.readLine().split(" "); int wi[]=new int[n]; for(int i=0;i<n;i++)wi[i]=Integer.parseInt(w[i]); Arrays.sort(wi); int ans=0,s=l,i=0; do { if(s>=wi[i]) { s-=wi[i]; ans++; } else break; //System.out.println(s); i++; }while(s>=0&&i<n); System.out.println(ans); } }