TopCoder problem "AutoMarket" used in SRM 233 (Division II Level Three)



Problem Statement

    It is expected that the more expensive the automobile, the more features are included and the less often it breaks down. While expected, this is not always true. Given a set of automobile specs, find the largest subset where the condition is reversed.



Write a class AutoMarket that contains a method maxSet, which accepts a int[] cost, int [] features and int[] fixTimes and returns the size of the largest subset that can be ordered such that each succeeding automobile costs more, has less features and must be fixed more often. All conditions are strict. The ith element in cost, features and fixTimes represents the ith car, which costs cost[i] dollars, has features[i] features and must be fixed fixTimes[i] times per year.
 

Definition

    
Class:AutoMarket
Method:maxSet
Parameters:int[], int[], int[]
Returns:int
Method signature:int maxSet(int[] cost, int[] features, int[] fixTimes)
(be sure your method is public)
    
 

Constraints

-cost, features and fixTimes will each have between 1 and 50 elements, inclusive.
-cost, features and fixTimes will have the same number of elements.
-Each element of cost will be between 1 and 100000, inclusive.
-Each element of features and fixTimes will be between 1 and 100, inclusive.
 

Examples

0)
    
{10000, 14000, 8000, 12000}
{1, 2, 4, 3}
{17, 15, 8, 11}
Returns: 3
The largest set contains all elements except the first.
1)
    
{1,2,3,4,5}
{1,2,3,4,5}
{1,2,3,4,5}
Returns: 1
2)
    
{9000, 6000, 5000, 5000, 7000}
{1, 3, 4, 5, 2}
{10, 6, 6, 5, 9}
Returns: 4
3)
    
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
{20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
Returns: 20
4)
    
{1000, 1000, 1000, 1000, 2000}
{3,3,4,3,3}
{3,3,3,4,3}
Returns: 1

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3937

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=6532&pm=3937

Writer:

ValD

Testers:

PabloGilberto , lbackstrom , brett1479

Problem categories:

Dynamic Programming, Graph Theory, Sorting