Problem link:
https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc7/00000000001d3f56#problem
 
I was solving allocation problem of Kick start 2020. My code works fine 
when executed locally I have even checked it test case having one house and 
its giving correct answer. Please have a look and tell me whats going wrong.

*CODE:*
#include<bits/stdc++.h>
using namespace std;

int main()
{
long long int test;
cin>>test;
vector<long long int> ans;
for(long long int i=1;i<=test;i++)
{
long long int n,b,sum=0,count=0,j;
cin>>n>>b;
vector<long long int> house(n);
for(j=0;j<n;j++)
{
cin>>house[j];
}
sort(house.begin(),house.end());
for(j=0;j<n;j++)
{
if(sum+house[j]<=b)
{
sum=+house[j];
count++;
}
}
ans.push_back(count);
}
for(int j=0;j<ans.size();j++)
{
cout<<"Case #"<<j+1<<": "<<ans[j]<<"\n"; 
}
} 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/9b61b112-d3cf-4e65-982c-e91c0aabb432n%40googlegroups.com.

Reply via email to