#P12262. 『STA - R9』交错
『STA - R9』交错
Problem Description
A sequence of length is called an interleaving sequence if and only if it has the form and .
You are given a sequence of length and modifications. In each modification, two positive integers and are given, and is set. You need to find the length of the longest interleaving subsequence of initially (i.e., before the first modification) and after each modification.
Input Format
The first line contains a positive integer .
The second line contains positive integers, denoting .
The third line contains a non-negative integer .
The next lines each contain two positive integers , denoting one modification.
Output Format
Output lines.
The first line is the length of the longest interleaving subsequence of initially.
The next lines: the -th line is the length of the longest interleaving subsequence of after the -th modification.
5
2 3 1 3 3
1
2 3
3
3
Hint
This problem uses bundled testdata, and the subtasks are as follows:
| Subtask ID | Special Property | Score | ||
|---|---|---|---|---|
| 0 | None | |||
| 1 | ||||
| 2 | ||||
| 3 | None | |||
| 4 | ||||
| 5 | ||||
| 6 | ||||
| 7 |
For of the data, it is guaranteed that , , and .
Translated by ChatGPT 5