#abc247g. G - Dream Team
G - Dream Team
Score : points
问题描述
有 名竞赛程序员。
第 名竞赛程序员属于大学 ,擅长科目 ,并且能力值为 。
考虑由这 人中的一些人组成的团队。如果满足以下两个条件,我们称这样的团队为 梦之队:
- 团队中的任意两个人都来自不同的大学。
- 团队中的任意两个人擅长的科目都不相同。
令 为梦之队的最大可能成员数。对于每个 ,解决以下问题。
问题:找出由 人组成的梦之队中人员能力值最大和是多少?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are competitive programmers.
The -th competitive programmer belongs to University , is good at Subject , and has a power of .
Consider a team consisting of some of the people. Let us call such a team a dream team if both of the following conditions are satisfied:
- Any two people belonging to the team belong to different universities.
- Any two people belonging to the team are good at different subjects.
Let be the maximum possible number of members of a dream team. For each , solve the following question.
Question: find the maximum sum of power of people belonging to a dream team consisting of people.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Let be the maximum possible number of members of a dream team.
Print in the first line. Then, print more lines, each containing the answer to the question for , in this order.
Sample Input 1
3
1 1 100
1 20 10
2 1 1
Sample Output 1
2
100
11
- The sum of power of members of a dream team consisting of exactly person is , when the team consists of the -st competitive programmer.
- The sum of power of members of a dream team consisting of exactly people is , when the team consists of the -nd and the -rd competitive programmers.
- It is impossible to form a dream team consisting of exactly people.
Sample Input 2
10
1 4 142135623
2 6 457513110
3 1 622776601
5 1 961524227
2 2 360679774
2 4 494897427
3 7 416573867
5 2 915026221
1 7 320508075
5 3 851648071
Sample Output 2
4
961524227
1537802822
2032700249
2353208324
update @ 2024/3/10 10:36:19