結果
| 問題 | 
                            No.156 キャンディー・ボックス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-01-18 23:20:54 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 809 bytes | 
| コンパイル時間 | 4,238 ms | 
| コンパイル使用メモリ | 75,084 KB | 
| 実行使用メモリ | 37,384 KB | 
| 最終ジャッジ日時 | 2024-12-24 07:55:17 | 
| 合計ジャッジ時間 | 7,578 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 2 | 
| other | AC * 8 WA * 22 | 
ソースコード
package me.yukicoder.lv1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class No0156 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] s1 = br.readLine().split(" ");
			String[] s2 = br.readLine().split(" ");
			int N = Integer.parseInt(s1[0]);
			int M = Integer.parseInt(s1[1]);
			int[] candy = new int[N];
			int cntBox = 0;
			for (int i = 0; i < N; i++) {
				candy[i] = Integer.parseInt(s2[cntBox]);
			}
			Arrays.sort(candy);
			for (cntBox = 0; cntBox < N; cntBox++) {
				M -= candy[cntBox];
				if (M < 0) {
					break;
				}
			}
			System.out.println(cntBox + 1);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}