結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2015-03-04 23:23:33 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 374 bytes |
コンパイル時間 | 1,944 ms |
コンパイル使用メモリ | 75,328 KB |
実行使用メモリ | 54,460 KB |
最終ジャッジ日時 | 2024-06-24 07:33:49 |
合計ジャッジ時間 | 7,439 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 RE * 2 |
ソースコード
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){ if(m>=kya[ans])ans++; m-=kya[ans-1]; } System.out.println(ans); } }