CF1223C.Save the Nature
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!
You have n tickets to sell. The price of the i-th ticket is pi. As a teller, you have a possibility to select the order in which the tickets will be sold (i.e. a permutation of the tickets). You know that the cinema participates in two ecological restoration programs applying them to the order you chose:
- The x% of the price of each the a-th sold ticket (a-th, 2a-th, 3a-th and so on) in the order you chose is aimed for research and spreading of renewable energy sources.
- The y% of the price of each the b-th sold ticket (b-th, 2b-th, 3b-th and so on) in the order you chose is aimed for pollution abatement.
If the ticket is in both programs then the (x+y)% are used for environmental activities. Also, it's known that all prices are multiples of 100, so there is no need in any rounding.
For example, if you'd like to sell tickets with prices [400,100,300,200] and the cinema pays 10% of each 2-nd sold ticket and 20% of each 3-rd sold ticket, then arranging them in order [100,200,300,400] will lead to contribution equal to 100⋅0+200⋅0.1+300⋅0.2+400⋅0.1=120. But arranging them in order [100,300,400,200] will lead to 100⋅0+300⋅0.1+400⋅0.2+200⋅0.1=130.
Nature can't wait, so you decided to change the order of tickets in such a way, so that the total contribution to programs will reach at least k in minimum number of sold tickets. Or say that it's impossible to do so. In other words, find the minimum number of tickets which are needed to be sold in order to earn at least k.
你内心是一名环保活动家,但现实很残酷——你只是电影院的一名收银员。不过,你依然可以有所作为!
你手上有 n 张待售电影票。第 i 张票的价格为 pi。作为售票员,你可以自主决定这些票的出售顺序(即对这些票进行任意排列)。你了解到,该电影院参与了两项生态修复计划,且这两项计划将依据你所选定的售票顺序来实施:
- 对于你所选定顺序中第 a 张、第 2a 张、第 3a 张……售出的票(即所有下标为 a 的倍数的位置),其票价的 x% 将用于可再生能源的研究与推广;
- 对于你所选定顺序中第 b 张、第 2b 张、第 3b 张……售出的票(即所有下标为 b 的倍数的位置),其票价的 y% 将用于污染治理。
若某张票同时满足上述两个条件(即其位置既是 a 的倍数又是 b 的倍数),则其票价的 (x+y)% 将全部用于环保活动。此外,已知所有票价均为 100 的倍数,因此无需任何取整操作。
例如,若待售票价格为 [400,100,300,200],影院对每第 2 张售出的票抽取 10%,对每第 3 张售出的票抽取 20%,那么按顺序 [100,200,300,400] 售票,环保贡献总额为
100⋅0+200⋅0.1+300⋅0.2+400⋅0.1=120.
而按顺序 [100,300,400,200] 售票,则贡献总额为
100⋅0+300⋅0.1+400⋅0.2+200⋅0.1=130.
大自然等不及了,因此你决定调整售票顺序,使得环保项目获得的总贡献至少达到 k 所需售出的票数尽可能少;若无法达成目标,则说明这是不可能的。换言之,请找出达成环保贡献至少为 k 所需售出的最少票数。
输入格式
The first line contains a single integer q (1≤q≤100) — the number of independent queries. Each query consists of 5 lines.
The first line of each query contains a single integer n (1≤n≤2⋅105) — the number of tickets.
The second line contains n integers p1,p2,…,pn (100≤pi≤109, pimod100=0) — the corresponding prices of tickets.
The third line contains two integers x and a (1≤x≤100, x+y≤100, 1≤a≤n) — the parameters of the first program.
The fourth line contains two integers y and b (1≤y≤100, x+y≤100, 1≤b≤n) — the parameters of the second program.
The fifth line contains single integer k (1≤k≤1014) — the required total contribution.
It's guaranteed that the total number of tickets per test doesn't exceed 2⋅105.
第一行包含一个整数 q(1≤q≤100),表示独立查询的次数。每次查询包含 5 行。
每次查询的第一行包含一个整数 n(1≤n≤2⋅105),表示票的数量。
每次查询的第二行包含 n 个整数 p1,p2,…,pn(100≤pi≤109,且 pimod100=0),表示对应票的价格。
每次查询的第三行包含两个整数 x 和 a(1≤x≤100,x+y≤100,1≤a≤n),表示第一个方案的参数。
每次查询的第四行包含两个整数 y 和 b(1≤y≤100,x+y≤100,1≤b≤n),表示第二个方案的参数。
每次查询的第五行包含一个整数 k(1≤k≤1014),表示所需的总贡献值。
保证每个测试用例中票的总数不超过 2⋅105。
输出格式
Print q integers — one per query.
For each query, print the minimum number of tickets you need to sell to make the total ecological contribution of at least k if you can sell tickets in any order.
If the total contribution can not be achieved selling all the tickets, print −1.
输出 q 个整数——每个查询对应一个整数。
对于每个查询,输出为使生态贡献总和至少达到 k 所需售出的最少票数(你可以按任意顺序售票)。
如果售出所有票仍无法达到该总贡献,则输出 −1。
输入输出样例
输入#1
4 1 100 50 1 49 1 100 8 100 200 100 200 100 200 100 100 10 2 15 3 107 3 1000000000 1000000000 1000000000 50 1 50 1 3000000000 5 200 100 100 100 100 69 5 31 2 90
输出#1
-1 6 3 4
说明/提示
In the first query the total contribution is equal to 50+49=99<100, so it's impossible to gather enough money.
In the second query you can rearrange tickets in a following way: [100,100,200,200,100,200,100,100] and the total contribution from the first 6 tickets is equal to 100⋅0+100⋅0.1+200⋅0.15+200⋅0.1+100⋅0+200⋅0.25=10+30+20+50=110.
In the third query the full price of each ticket goes to the environmental activities.
In the fourth query you can rearrange tickets as [100,200,100,100,100] and the total contribution from the first 4 tickets is 100⋅0+200⋅0.31+100⋅0+100⋅0.31=62+31=93.
在第一次查询中,总捐款额为 50+49=99<100,因此无法筹集到足够的资金。
在第二次查询中,你可以将门票重新排列为:[100,100,200,200,100,200,100,100],前 6 张门票的总捐款额为 100⋅0+100⋅0.1+200⋅0.15+200⋅0.1+100⋅0+200⋅0.25=10+30+20+50=110。
在第三次查询中,每张门票的全部票价均用于环保活动。
在第四次查询中,你可以将门票重新排列为 [100,200,100,100,100],前 4 张门票的总捐款额为 100⋅0+200⋅0.31+100⋅0+100⋅0.31=62+31=93。
输入解题思路,AI测评打分。不知道怎么写?