#P10153. 「LAOI-5」膜你赛

    ID: 11214 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>贪心洛谷原创Special JudgeO2优化构造

「LAOI-5」膜你赛

Background

LAOI members created a CSP-J mock contest with 1010010^{100} problems.

2025.1.24 The idea of this problem comes from xzCyanBrad.

Problem Description

The contest uses the ICPC rules: first sort by the number of solved problems in non-increasing order, then sort by the total penalty time in non-decreasing order.

There are nn top players coming to speedrun this contest, and the contest lasts mm minutes in total.

At the beginning of minute ii (0im10 \le i \le m-1), player sis_i first submits tit_i WA submissions (each adds xx minutes of penalty), and then solves one problem. So their solved count increases by 11, and their total penalty time increases by x×ti+ix \times t_i + i minutes.

Player ii has a total of kik_i WA submissions and solves aia_i problems (it is guaranteed that i=1nai=m\sum_{i=1}^n a_i = m). Why did they not finish all problems? Because they thought the problems were too easy and not interesting, so they left.

If player ii finds that they are in first place on the leaderboard (no ties allowed) after finishing all of their submissions, then we say they "speedrun the contest."

Construct sequences {sm}\{s_m\} and {tm}\{t_m\} such that player ii has exactly kik_i WAs and solves exactly aia_i problems, and the number of players who "speedrun the contest" is as large as possible.

Input Format

There are three lines in total.

The first line contains three integers n,m,xn,m,x.

The second line contains nn integers, representing {an}\{a_n\}.

The third line contains nn integers, representing {kn}\{k_n\}.

Output Format

Output the maximum number of players who "speedrun the contest" on the first line.

On the second and third lines, output one optimal construction:

The second line contains mm integers, representing {sm}\{s_m\}.

The third line contains mm integers, representing {tm}\{t_m\}.

3 9 20
3 3 3
0 1 2
3
3 3 3 2 2 2 1 1 1
1 0 1 0 1 0 0 0 0
3 16 3
5 5 6
2 0 8
3
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 3
0 0 1 0 0 1 1 0 2 1 0 2 0 0 1 1

Hint

Sample 1 Explanation

At minute 22, player 33 finishes submitting, solves 33 problems, and has penalty time 20×2+0+1+2=4320 \times 2 + 0 + 1 + 2 = 43 minutes.

At minute 55, player 22 finishes submitting, solves 33 problems, and has penalty time 20×1+3+4+5=3220 \times 1 + 3 + 4 + 5 = 32 minutes.

At minute 88, player 11 finishes submitting, solves 33 problems, and has penalty time 20×0+6+7+8=2120 \times 0 + 6 + 7 + 8 = 21 minutes.

Constraints

The testdata is not guaranteed to be random.

This problem uses bundled tests.

Subtask ID Score n,m,xn,m,x
11 1010 n5n\le5m50m \le50x5x\le5
22 n50n\le50m500m\le500
33 2020 n103n\le10^3m5×103m \le5\times10^3
44 x=0x=0ki=0k_i=0
55 4040 No special limits.

For 100%100\% of the testdata, it is guaranteed that:

  • m3nm\ge 3n
  • 3n1053 \le n\le10^5
  • 9m3×1059\le m\le 3\times10^5
  • 0x5×1040\le x\le 5\times10^4
  • 0ki4×1040\le k_i \le 4\times10^4
  • 3ai3×1053\le\color{black} a_i \le 3\times10^5
  • i=1nai=m\sum ^{n}_{i=1} a_i = m

Translated by ChatGPT 5