Andrew and the Meatballs

below is code in php. its showing wrong answer please help

#!C:\wamp\bin\php\php5.3.13\php.exe -q
<?php
	fscanf(STDIN,"%d",$tt);
	$res[]='';
	for($i=0;$i<$tt;$i++){
		fscanf(STDIN,"%d %d",$n,$k);
		$t=explode(' ',trim(fgets(STDIN)));
		rsort($t);
		$sum=0;
		$c=0;
		$f=0;
		foreach($t as $a){
			$sum+=$a;
			$c++;
			if($sum>=$k){
				$f=1;
				break;
			}
		}
		if($f==1)
			$res[$i]=$c;
		else
			$res[$i]=-1;
	}
	foreach($res as $re)
		printf("%d\n",$re);
	exit(0); 
?>