CF1650F.Vitaly and Advanced Useless Algorithms

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vitaly enrolled in the course Advanced Useless Algorithms. The course consists of nn tasks. Vitaly calculated that he has aia_i hours to do the task ii from the day he enrolled in the course. That is, the deadline before the ii-th task is aia_i hours. The array aa is sorted in ascending order, in other words, the job numbers correspond to the order in which the assignments are turned in.

Vitaly does everything conscientiously, so he wants to complete each task by 100100 percent, or more. Initially, his completion rate for each task is 00 percent.

Vitaly has mm training options, each option can be used not more than once. The iith option is characterized by three integers: ei,tie_i, t_i and pip_i. If Vitaly uses the iith option, then after tit_i hours (from the current moment) he will increase the progress of the task eie_i by pip_i percent.

For example, let Vitaly have 33 of tasks to complete. Let the array aa have the form: a=[5,7,8]a = [5, 7, 8]. Suppose Vitaly has 55 of options: [e1=1,t1=1,p1=30][e_1=1, t_1=1, p_1=30], [e2=2,t2=3,p2=50][e_2=2, t_2=3, p_2=50], [e3=2,t3=3,p3=100][e_3=2, t_3=3, p_3=100], [e4=1,t4=1,p4=80][e_4=1, t_4=1, p_4=80], [e5=3,t5=3,p5=100][e_5=3, t_5=3, p_5=100].

Then, if Vitaly prepares in the following way, he will be able to complete everything in time:

  • Vitaly chooses the 44-th option. Then in 11 hour, he will complete the 11-st task at 8080 percent. He still has 44 hours left before the deadline for the 11-st task.
  • Vitaly chooses the 33-rd option. Then in 33 hours, he will complete the 22-nd task in its entirety. He has another 11 hour left before the deadline for the 11-st task and 44 hours left before the deadline for the 33-rd task.
  • Vitaly chooses the 11-st option. Then after 11 hour, he will complete the 11-st task for 110110 percent, which means that he will complete the 11-st task just in time for the deadline.
  • Vitaly chooses the 55-th option. He will complete the 33-rd task for 22 hours, and after another 11 hour, Vitaly will complete the 33-rd task in its entirety.

Thus, Vitaly has managed to complete the course completely and on time, using the 44 options.

Help Vitaly — print the options for Vitaly to complete the tasks in the correct order. Please note: each option can be used not more than once. If there are several possible answers, it is allowed to output any of them.

维塔利报名了《高级无用算法》这门课程。该课程共有 nn 个任务。维塔利计算出,从他报名课程那天起,他完成第 ii 个任务仅有 aia_i 小时的时间。也就是说,第 ii 个任务的截止时间为报名后 aia_i 小时。数组 aa 按升序排列,换言之,任务编号即为其提交顺序。

维塔利做事非常认真,因此他希望每个任务的完成度均达到 100% 或更高。初始时,他对每个任务的完成度均为 0%。

维塔利共有 mm 种训练方案,每种方案最多只能使用一次。第 ii 种方案由三个整数 ei,tie_i, t_i 和 pip_i 描述:若维塔利采用第 ii 种方案,则从当前时刻起经过 tit_i 小时后,他将把第 eie_i 个任务的完成度提高 pip_i%。

例如,假设维塔利共有 33 个任务需完成,且数组 a=[5,7,8]a = [5, 7, 8]。又假设他有 55 种训练方案:
[e1=1,t1=1,p1=30][e_1=1, t_1=1, p_1=30],
[e2=2,t2=3,p2=50][e_2=2, t_2=3, p_2=50],
[e3=2,t3=3,p3=100][e_3=2, t_3=3, p_3=100],
[e4=1,t4=1,p4=80][e_4=1, t_4=1, p_4=80],
[e5=3,t5=3,p5=100][e_5=3, t_5=3, p_5=100]。

那么,若维塔利按如下方式准备,他便能按时完成全部任务:

  • 维塔利选择第 44 种方案。1 小时后,他将第 11 个任务的完成度提升至 80%。此时距第 11 个任务截止时间还剩 4 小时。
  • 维塔利选择第 33 种方案。3 小时后,他将第 22 个任务完全完成(100%)。此时距第 11 个任务截止时间还剩 1 小时,距第 33 个任务截止时间还剩 4 小时。
  • 维塔利选择第 11 种方案。再过 1 小时,他将第 11 个任务的完成度提升至 110%,即恰好在截止时间前完成第 11 个任务。
  • 维塔利选择第 55 种方案。他花费 2 小时进行训练,再过 1 小时后,第 33 个任务完成度达到 100%。

因此,维塔利成功地在截止时间前完整完成了全部课程,共使用了 4 种方案。

请帮助维塔利——输出他完成所有任务所需使用的方案编号(按执行顺序)。注意:每种方案最多只能使用一次。若存在多种可行解,输出任意一种即可。

输入格式

The first line of input data contains an integer TT (1≤T≤1041 \le T \le 10^4) —the number of input test cases in the test.

The descriptions of the input test case follow.

The first line of each test case description contains two integers nn and mm (1≤n,m≤1051 \le n,m \le 10^5) —the number of jobs and the number of training options, respectively.

The next line contains nn numbers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \le a_i \le 10^9) — the time before the deadline of job ii. The array values — are non-decreasing, that is a1≤a2≤⋯≤ana_1 \le a_2 \le \dots \le a_n.

The following mm lines contain triples of numbers ei,ti,pie_i, t_i, p_i (1≤ei≤n1 \le e_i \le n, 1≤ti≤1091 \le t_i \le 10^9, 1≤pi≤1001 \le p_i \le 100) — if Vitaly chooses this option, then after tit_i hours he will increase the progress of the task eie_i by pip_i percent. The options are numbered from 11 to mm in order in the input data.

It is guaranteed that the sum of n+mn+m on all test cases does not exceed 2⋅1052 \cdot 10^5.

输入数据的第一行包含一个整数 TT(1≤T≤1041 \le T \le 10^4)——表示测试中输入测试用例的数量。

接下来是各输入测试用例的描述。

每个测试用例描述的第一行包含两个整数 nn 和 mm(1≤n,m≤1051 \le n,m \le 10^5)——分别表示任务数量和培训选项数量。

下一行包含 nn 个数字 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \le a_i \le 10^9)——表示第 ii 个任务截止前的剩余时间。该数组值为非递减序列,即满足 a1≤a2≤⋯≤ana_1 \le a_2 \le \dots \le a_n。

随后的 mm 行每行包含三个数字 ei,ti,pie_i, t_i, p_i(1≤ei≤n1 \le e_i \le n, 1≤ti≤1091 \le t_i \le 10^9, 1≤pi≤1001 \le p_i \le 100)——若 Vitaly 选择该选项,则经过 tit_i 小时后,任务 eie_i 的完成进度将提升 pip_i 个百分点。这些选项按输入顺序编号为 11 至 mm。

保证所有测试用例中 n+mn+m 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, print on the first line the number kk, meaning that for kk of options, Vitaly will be able to complete each task by 100100 percent or more on time. The options should not be repeated. Or print -1 if Vitaly is unable to complete all tasks in time.

If there is an answer, on the next line print kk of different integers from 11 to mm — the numbers of the options in the order you want. If there is more than one answer, it is allowed to print any of them.

对于每个测试用例,在第一行输出一个整数 kk,表示在 kk 个选项中,Vitaly 能够以 100%100\% 或更高的完成率按时完成所有任务。这些选项不能重复。如果 Vitaly 无法在规定时间内完成所有任务,则输出 −1-1。

如果存在解,则在下一行输出 kk 个互不相同的、取值范围为 11 到 mm 的整数——即所选选项的编号(按你指定的顺序)。若存在多个可行解,输出任意一个即可。

输入输出样例

  • 输入#1

    5
    3 5
    5 7 8
    1 1 30
    2 3 50
    2 3 100
    1 1 80
    3 3 100
    1 5
    51
    1 36 91
    1 8 40
    1 42 83
    1 3 45
    1 13 40
    2 9
    9 20
    2 8 64
    2 7 64
    1 20 56
    2 8 76
    2 20 48
    1 2 89
    1 3 38
    2 18 66
    1 7 51
    3 2
    7 18 33
    1 5 80
    3 4 37
    2 5
    569452312 703565975
    1 928391659 66
    1 915310 82
    2 87017081 92
    1 415310 54
    2 567745964 82

    输出#1

    4
    1 4 3 5 
    3
    2 4 5 
    4
    6 7 1 2 
    -1
    4
    2 4 3 5
  • 输入#2

    3
    3 9
    20 31 40
    1 9 64
    3 17 100
    3 9 59
    3 18 57
    3 20 49
    2 20 82
    2 14 95
    1 8 75
    2 16 67
    2 6
    20 36
    2 2 66
    2 20 93
    1 3 46
    1 10 64
    2 8 49
    2 18 40
    1 1
    1000000000
    1 1000000000 100

    输出#2

    -1
    4
    3 4 1 5 
    1
    1

输入解题思路,AI测评打分。不知道怎么写?

首页