結果

提出番号 1651
提出者 fal_rnd
言語 Java
提出日時 2018-08-04 13:22:35
問題名 (68)単位
結果 AC
点数 100%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 100% 191ms 124400KB
2 AC 100% 184ms 122464KB
3 AC 100% 161ms 122048KB
4 AC 100% 182ms 124400KB
5 AC 100% 149ms 123520KB
6 AC 100% 173ms 124208KB
7 AC 100% 144ms 125264KB
8 AC 100% 180ms 125280KB
9 AC 100% 173ms 122048KB
10 AC 100% 176ms 121696KB
11 AC 100% 142ms 123056KB
12 AC 100% 174ms 123968KB
13 AC 100% 183ms 122528KB
14 AC 100% 168ms 122384KB
15 AC 100% 144ms 122832KB
16 AC 100% 186ms 124640KB
17 AC 100% 182ms 123168KB
18 AC 100% 151ms 126016KB
19 AC 100% 161ms 121456KB
20 AC 100% 165ms 123216KB
21 AC 100% 208ms 124496KB
22 AC 100% 191ms 124432KB
23 AC 100% 149ms 121840KB
24 AC 100% 197ms 122288KB
25 AC 100% 181ms 124768KB
26 AC 100% 196ms 121552KB
27 AC 100% 144ms 122320KB
28 AC 100% 191ms 124560KB
29 AC 100% 149ms 122688KB
30 AC 100% 152ms 122400KB
31 AC 100% 172ms 125008KB
32 AC 100% 207ms 122768KB
33 AC 100% 146ms 125264KB
34 AC 100% 179ms 123040KB
35 AC 100% 169ms 121728KB
36 AC 100% 142ms 123648KB
37 AC 100% 193ms 123184KB
38 AC 100% 185ms 123392KB
39 AC 100% 171ms 123312KB
40 AC 100% 164ms 125344KB
41 AC 100% 159ms 124608KB
42 AC 100% 141ms 123632KB
43 AC 100% 184ms 122768KB
44 AC 100% 148ms 122016KB
45 AC 100% 143ms 122304KB
46 AC 100% 150ms 122224KB
47 AC 100% 178ms 121424KB
48 AC 100% 230ms 124016KB
49 AC 100% 160ms 123728KB
50 AC 100% 161ms 124912KB
51 AC 100% 156ms 122800KB
52 AC 100% 168ms 123280KB
53 AC 100% 160ms 125856KB
54 AC 100% 162ms 122000KB
55 AC 100% 167ms 122528KB
56 AC 100% 177ms 124960KB
57 AC 100% 149ms 122240KB
58 AC 100% 169ms 126480KB
59 AC 100% 190ms 124928KB
60 AC 100% 139ms 123104KB

ソースコード

import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	void solve(){
		int n=gInt(),m=gInt();
		int[]v=INTS(n).sorted().toArray();
		int i=0;
		for(;m>0;++i) {
			m-=v[n-i-1];
		}
		System.out.println(i);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return new Range(i);
	}
	Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int n){
		return REP(0,n-1);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}
}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
}