結果

問題 No.156 キャンディー・ボックス
ユーザー TatsuDX
提出日時 2016-09-09 00:03:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 431 bytes
コンパイル時間 3,179 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 41,412 KB
最終ジャッジ日時 2024-07-05 15:55:41
合計ジャッジ時間 7,322 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(), m = sc.nextInt();
		int[] t = new int[n];
		for(int i = 0; i < n; i++){
			t[i] = sc.nextInt();
		}
		Arrays.sort(t);
		for(int i = 0; i < n; i++){
			m -= t[i];
			if(m < 0){
				System.out.println(i);
				return;
			}
		}
		System.out.println(n);
	}
}
0