CF1787H.Codeforces Scoreboard
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are participating in a Codeforces Round with n problems.
You spend exactly one minute to solve each problem, the time it takes to submit a problem can be ignored. You can only solve at most one problem at any time. The contest starts at time 0, so you can make your first submission at any time t≥1 minutes. Whenever you submit a problem, it is always accepted.
The scoring of the i-th problem can be represented by three integers ki, bi, and ai. If you solve it at time t minutes, you get max(bi−ki⋅t,ai) points.
Your task is to choose an order to solve all these n problems to get the maximum possible score. You can assume the contest is long enough to solve all problems.
你正在参加一场有 n 道题的 Codeforces 比赛。
每道题恰好花费你一分钟来解决,提交题目所需的时间可忽略不计;在任意时刻你最多只能解决一道题。比赛从时间 0 开始,因此你的第一次提交最早可在 t≥1 分钟时进行。每次你提交一道题,该题总会被接受。
第 i 道题的得分规则由三个整数 ki、bi 和 ai 表示:若你在 t 分钟时解决该题,则获得 max(bi−ki⋅t,ai) 分。
你的任务是选择一个解题顺序,使得所有 n 道题的总得分最大。你可以假定比赛时间足够长,足以解决全部题目。
输入格式
Each test contains multiple test cases. The first line contains an integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains one integer n (1≤n≤2⋅105) — the number of problems.
The n lines follow, the i-th of them contains three integers ki, bi, ai (1≤ki,bi,ai≤109; ai<bi), denoting that you get the score of max(bi−ki⋅t,ai) if you solve the i-th task at time t minutes.
It's guaranteed that the sum of n does not exceed 2⋅105.
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤2⋅105),表示题目的数量。
接下来 n 行,其中第 i 行包含三个整数 ki、bi、ai(1≤ki,bi,ai≤109;且 ai<bi),表示:若你在第 t 分钟解决第 i 道题目,则获得的分数为 max(bi−ki⋅t,ai)。
保证所有测试用例中 n 的总和不超过 2⋅105。
输出格式
For each test case, print a line containing a single integer — the maximum score you can get.
对于每个测试用例,输出一行,包含一个整数——你能获得的最高分数。
输入输出样例
输入#1
4 4 10000 1000000000 2006 10000 1000000000 9999 2 999991010 1010 1000000000 1000000000 999999999 6 1 8 1 9 29 4 2 14 3 4 13 1 2 19 5 10 12 5 8 4 10 1 4 19 8 1 14 3 4 15 6 2 9 6 1 11 10 2 19 12 4 19 14 10 5 12 7 5 39 12 2 39 11 3 23 15 5 30 11 3 17 13 5 29 14 3 17 11 3 36 18 3 9 8
输出#1
3999961003 53 78 180
说明/提示
In the second test case, the points for all problems at each minute are listed below.
Time
1
2
3
4
5
6
Problem 1
7
6
5
4
3
2
Problem 2
20
11
4
4
4
4
Problem 3
12
10
8
6
4
3
Problem 4
9
5
1
1
1
1
Problem 5
17
15
13
11
9
7
Problem 6
5
5
5
5
5
5
The points displayed in red denote one of the optimal orders with the score 53.
在第二个测试用例中,每道题目在每一分钟的得分如下所示:
时间
1
2
3
4
5
6
题目 1
7
6
5
4
3
2
题目 2
20
11
4
4
4
4
题目 3
12
10
8
6
4
3
题目 4
9
5
1
1
1
1
题目 5
17
15
13
11
9
7
题目 6
5
5
5
5
5
5
标为红色的得分表示一种最优解顺序,其总得分为 53。
输入解题思路,AI测评打分。不知道怎么写?