結果

問題 No.156 キャンディー・ボックス
ユーザー mits58mits58
提出日時 2016-07-02 13:36:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 71,756 KB
実行使用メモリ 55,800 KB
最終ジャッジ日時 2023-09-19 03:11:28
合計ジャッジ時間 8,032 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,484 KB
testcase_01 AC 128 ms
55,408 KB
testcase_02 AC 127 ms
55,516 KB
testcase_03 AC 127 ms
55,448 KB
testcase_04 AC 128 ms
55,796 KB
testcase_05 AC 128 ms
55,596 KB
testcase_06 AC 131 ms
55,560 KB
testcase_07 AC 130 ms
55,620 KB
testcase_08 AC 131 ms
55,800 KB
testcase_09 AC 130 ms
55,628 KB
testcase_10 AC 126 ms
55,556 KB
testcase_11 AC 127 ms
55,336 KB
testcase_12 AC 127 ms
55,604 KB
testcase_13 AC 127 ms
55,544 KB
testcase_14 AC 128 ms
55,692 KB
testcase_15 AC 130 ms
55,628 KB
testcase_16 AC 129 ms
55,404 KB
testcase_17 AC 126 ms
55,596 KB
testcase_18 AC 129 ms
55,592 KB
testcase_19 AC 127 ms
55,588 KB
testcase_20 AC 126 ms
55,588 KB
testcase_21 AC 131 ms
55,592 KB
testcase_22 AC 127 ms
55,476 KB
testcase_23 AC 127 ms
55,328 KB
testcase_24 AC 127 ms
55,664 KB
testcase_25 AC 128 ms
55,528 KB
testcase_26 AC 127 ms
55,324 KB
testcase_27 AC 127 ms
55,700 KB
testcase_28 AC 128 ms
55,492 KB
testcase_29 AC 127 ms
55,600 KB
testcase_30 AC 128 ms
55,572 KB
testcase_31 AC 128 ms
55,744 KB
testcase_32 AC 128 ms
53,376 KB
testcase_33 AC 130 ms
55,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			long m=sc.nextLong();
			long[] c=new long[n];
			for(int i=0;i<n;i++) c[i]=sc.nextLong();
			Arrays.sort(c);
			for(int i=0;i<n;i++){
				m-=c[i];
				if(m==0){
					System.out.println(i+1);
					break;
				}
				else if(m<0){
					System.out.println(i);
					break;
				}
			}
		}
	}
}
0