#P9553. 「CROI · R1」浣熊的语言

「CROI · R1」浣熊的语言

Background

[2023.08.17 21:44]:\texttt{[2023.08.17 21:44]:} To prevent some magical brute-force solutions from passing, the time limit of this problem has been changed to 500 ms500\ ms.

He half-closes his eyes, reading the words on the sand.
Lines and phrases, recited day and night, his pen dancing like the wind; under the night, stars are scattered everywhere.
New ideas, about to emerge, so close yet slipping away; with a sigh, success falls short at the last moment.
She smiles in relief, stands up calmly, and lightly taps his back.
Then, in streaks of light, bear claws flutter; in the night wind, new words become clear.
“You did it……”
An ordinary midsummer night, profound words.
The effort of reciting, shimmering with starlight……

Problem Description

The little raccoon CleverRaccoon follows the raccoon word-forgetting curve and starts memorizing words from day 11.

There are nn words in total. Normally, the ii-th word will be learned for the first time on day did_i.

Meanwhile, each word is scheduled for kk reviews. For the jj-th review, there is a review point tjt_j, meaning that normally, each word will be reviewed tjt_j days after its first learning. In other words, the time of the jj-th review for the ii-th word is day di+tjd_i + t_j.

In addition, there are mm days with special situations. The ii-th special situation happens on day sis_i. On that day, CleverRaccoon forgets to memorize words, and any first-learning or review schedule that conflicts with that day will be postponed to the next day.

  • If a word’s first-learning time is postponed to the next day, then the reviews of that word are arranged based on the postponed first-learning time.
  • If a word’s current review time is postponed to the next day, it does not affect the subsequent review times of that word.
  • If multiple learning or review events fall on the same day, then multiple learning or review actions must be done on that day.

CleverRaccoon wants to know: the number of days needed to finish learning and reviewing all words, the number of new words learned each day, and the number of words reviewed each day.

Input Format

The first line contains three integers n,m,kn, m, k, representing the total number of words to memorize, the number of special-situation days, and the number of reviews required for each word.

The second line contains nn integers did_i, representing the first-learning time of each word. It is guaranteed that dd is non-decreasing.

The third line contains mm integers sis_i, representing the dates of special situations. It is guaranteed that ss is strictly increasing. In particular, if m=0m = 0, then this line does not exist.

The fourth line contains kk integers tit_i, representing each review point for all words. It is guaranteed that tt is strictly increasing.

Output Format

The first line contains one integer, the number of days xx needed for CleverRaccoon to finish learning and reviewing all words.

Then there are xx lines. Each line contains two integers, representing the number of words newly learned and the number of words reviewed on that day.

5 0 2
1 1 1 2 3
1 2
5
3 0
1 3
1 4
0 2
0 1
5 1 2
1 1 1 2 3
1
1 2
5
0 0
4 0
1 4
0 5
0 1
5 1 3
1 2 3 4 5
3
1 2 3
8
1 0
1 1
0 0
2 4
1 3
0 3
0 3
0 1

Hint

Assume that the word indices in the input order are 1n1 \sim n.

Sample Explanation #1

Day New word indices Number of new words Reviewed word indices Number of reviewed words
11 1,2,31,2,3 33 - 00
22 44 11 1,2,31,2,3 33
33 55 1,2,3,41,2,3,4 44
44 - 00 4,54,5 22
55 55 11

Sample Explanation #2

Day New word indices Number of new words Reviewed word indices Number of reviewed words
11 (special) - 00 - 00
22 1,2,3,41,2,3,4 44
33 55 11 1,2,3,41,2,3,4 44
44 - 00 1,2,3,4,51,2,3,4,5 55
55 55 11

Sample Explanation #3

Day New word indices Number of new words Reviewed word indices Number of reviewed words
11 11 - 00
22 11
33 (special) - 00 - 00
44 3,43,4 22 1,1,2,21,1,2,2 44
55 11 2,3,42,3,4 33
66 - 00 3,4,53,4,5
77
88 55 11

Constraints

This problem uses bundled Subtask testdata.

For 100%100\% of the data, it is guaranteed that 1n1061 \leq n \leq 10^6, 0m2000 \leq m \leq 200, 1k,di,ti1031 \leq k, d_i, t_i \leq 10^3, sm<dns_m < d_n. It is guaranteed that dd is non-decreasing, and t,st, s are strictly increasing.

Subtask nn mm kk did_i tit_i Score
00 100\leq 100 =0=0 10\leq 10 100\leq 100 100\leq 100 55
11 103\leq 10^3 100\leq 100 103\leq 10^3 2020
22 100\leq 100 10\leq 10 100\leq 100 1515
33 103\leq 10^3 100\leq 100 103\leq 10^3 2525
44 106\leq 10^6 200\leq 200 103\leq 10^3 103\leq 10^3 3535

Translated by ChatGPT 5