Hi, I've written the following code for the *Allocation* problem of round 
1. It passes the basic test cases given in the problem description. But it 
fails upon submission. Could someone please point out what I might be 
missing?

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
   int tc; cin >> tc;  \\ test casese
   int arr_output[100000] = {0};   \\ array for answers
   for (int i = 0; i < tc; i++)
   {
       int houses, budget;
       cin >> houses; cin >> budget;
       int arr[houses];
       for(int j = 0; j < houses; ++j)
       {
           cin >> arr[j];
       }
       
       sort(arr, arr+houses);

        int buy_house = 0;  \\ answer
       
       for (int j = 0; j < houses; j++)
       {
           if (arr[j] <= budget)
           {
               buy_house += 1;
               budget = budget - arr[j];
           }
           else
           {
               break;
           }
           
       }
       arr_output[i] = buy_house;
       
   }
   for (int i = 0; i < tc; i++)
   {
       cout << arr_output[i] << "\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/687aaed0-2678-4471-a7f5-686c81babaa1%40googlegroups.com.

Reply via email to