WA in AMMEAT

wats wrong in my code…its giving wrong answer here but works fine for the test cases:http://www.codechef.com/viewsolution/3284399

For input

1
2 90000000000
1 90000000000

it returns 2 - http://ideone.com/qRFZei

Thanks…i corrected it…and got the answer

// Why i am getting wrong answer in my code even it follows all test case?
// Please someone help me
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n,i;
cin>>t;
while(t–)
{
int flag=0;
long long int m,a;
cin>>n>>m;
long long int p[n],s=0,c=0;
for(i=0;i<n;i++)
cin>>p[i];
sort(p,p+n);
reverse(p,p+n);
a=m;
for(i=0;i<n;i++)
{
if(p[i]<=m)
{
s=s+p[i];
c++;
m=m-p[i];
}
if(m==0)
{
cout<<c<<endl;flag=1;
break;
}
}
if(flag==0)cout<<"-1"<<endl;
}
return 0;
}