#P13486. [GCJ 2008 Finals] Juice

    ID: 15361 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 难度: 4 上传者: 标签>2008树状数组枚举排序STLGoogle Code Jam

[GCJ 2008 Finals] Juice

题目描述

You are holding a party. In preparation, you are making a drink by mixing together three different types of fruit juice: Apple, Banana, and Carrot. Let's name the juices AA, BB and CC.

You want to decide what fraction of the drink should be made from each type of juice, in such a way that the maximum possible number of people attending the party like it.

Each person has a minimum fraction of each of the 33 juices they would like to have in the drink. They will only like the drink if the fraction of each of the 33 juices in the drink is greater or equal to their minimum fraction for that juice.

Determine the maximum number of people that you can satisfy.

输入格式

  • One line containing an integer TT, the number of test cases in the input file.

For each test case, there will be:

  • One line containing the integer NN, the number of people going to the party.
  • NN lines, one for each person, each containing three space-separated numbers "AA BB CC", indicating the minimum fraction of each juice that would like in the drink. AA, BB and CC are integers between 00 and 1000010000 inclusive, indicating the fraction in parts-per-ten-thousand. A+B+C10000A + B + C \leq 10000.

输出格式

  • TT lines, one for each test case in the order they occur in the input file, each containing the string "Case #XX: YY" where XX is the number of the test case, starting from 11, and YY is the maximum number of people who will like your drink.
3
3
10000 0 0
0 10000 0
0 0 10000
3
5000 0 0
0 2000 0
0 0 4000
5
0 1250 0
3000 0 3000
1000 1000 1000
2000 1000 2000
1000 3000 2000
Case #1: 1
Case #2: 2
Case #3: 5

提示

Limits

In the first case, for each juice, we have one person that wants the drink to be made entirely out of that juice! Clearly we can only satisfy one of them.

In the second case, we can satisfy any two of the three preferences.

In the third case, all five people will like the drink if we make it using equal thirds of each juice.

Limits

  • 1T121 \leq T \leq 12

Small dataset (Test set 1 - Visible)

  • 1N101 \leq N \leq 10

Large dataset (Test set 2 - Hidden)

  • 1N50001 \leq N \leq 5000