結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2015-03-04 23:17:19 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 372 bytes |
コンパイル時間 | 3,124 ms |
コンパイル使用メモリ | 74,744 KB |
実行使用メモリ | 56,460 KB |
最終ジャッジ日時 | 2024-06-24 06:41:31 |
合計ジャッジ時間 | 7,803 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 12 WA * 18 |
ソースコード
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] kya = new int[n]; for(int i=0;i<n;i++){ kya[i]=sc.nextInt(); } Arrays.sort(kya); int ans=0; while(m>0&&ans<n){ m-=Math.min(m, kya[ans]); ans++; } System.out.println(ans-1); } }