title: Maximum Removal From Array When Removal Time Waiting Time
signature: maximumRemovalFromArrayWhenRemovalTimeWaitingTime(arr, n) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(arr, n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          [7, 33, 34, 42, 42, 45, 73], 5, 
          3)
      }");
  
      print("TEST-1...${driver(
          [-98, -90, -80, -66, -64, -62, -48, -30, -20, -10, 4, 6, 12, 14, 32, 42, 44, 44, 52, 64, 86, 92, 94], 16, 
          4)
      }");
  
      print("TEST-2...${driver(
          [0, 0, 0, 0, 1], 2, 
          2)
      }");
  
      print("TEST-3...${driver(
          [11, 44, 71, 82, 85, 89], 3, 
          3)
      }");
  
      print("TEST-4...${driver(
          [-96, -92, -78, -72, -68, -58, -52, -50, -50, -48, -42, -32, -20, -18, -4, 0, 0, 2, 18, 18, 20, 24, 32, 34, 36, 38, 38, 60, 66, 68, 70, 72, 72, 74, 76, 96, 98], 21, 
          5)
      }");
  
      print("TEST-5...${driver(
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 16, 
          11)
      }");
  
      print("TEST-6...${driver(
          [8, 9, 10, 11, 12, 15, 17, 19, 20, 21, 24, 30, 33, 35, 36, 39, 41, 41, 42, 54, 62, 63, 68, 70, 71, 72, 77, 85, 86, 86, 94, 95, 97, 97], 31, 
          5)
      }");
  
      print("TEST-7...${driver(
          [-94, -90, -72, -70, -66, -60, -24, -16, 4, 4, 10, 22, 28, 36, 46, 60, 70, 72, 76, 92, 96], 20, 
          6)
      }");
  
      print("TEST-8...${driver(
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 13, 
          13)
      }");
  
      print("TEST-9...${driver(
          [7, 10, 12, 16, 20, 28, 31, 40, 42, 47, 53, 57, 59, 63, 63, 67, 69, 84, 90, 97], 10, 
          4)
      }");
  
      return 0;
  }
source_py: def maximum_removal_from_array_when_removal_time_waiting_time(arr, n):
      count = 0
      cummulative_sum = 0
      arr.sort()
      for i in range(n):
          if (arr[i] >= cummulative_sum):
              count += 1
              cummulative_sum += arr[i]
      return count
source_cpp: int maximum_removal_from_array_when_removal_time_waiting_time(vector<int> arr, int n) {
    int count = 0;
    int cummulative_sum = 0;
    sort(arr.begin(), arr.end());
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( arr [ i ] >= cummulative_sum ) {
        count ++;
        cummulative_sum += arr [ i ];
      }
    }
    return count;
  }