#P11069. 「QMSOI R1」 生熏鱼
「QMSOI R1」 生熏鱼
Background
Everything started with a general called Shen Xun Yu...
So where is the connection between this problem and Shen Xun Yu?
![]()
Background
Problem Description
There are types of attacks. The -th type of attack will first give you experience points, and then make you lose health points.
You will be attacked in order for times. The type of the -th attack is . Your initial health is .
To gain more experience, you may choose any one of the attack types and prevent the first attack of that chosen type from affecting you. After preventing it, you will neither lose health nor gain experience from that attack.
Now you want to know: before your health drops to or below, what is the maximum experience you can obtain.
Input Format
One line with 4 integers , where is the random seed. The meanings of the other variables are the same as in the statement.
Because the input is too large, you must generate the data in the following way:
const int M=1e9,C=1e5+5;
void read(){
cin>>n>>m>>k>>s;
mt19937 rand(s);
for(int i=1;i<=n;i++) a[i]=rand()%M+1,b[i]=rand()%C+1;
for(int i=1;i<=k;i++) c[i]=rand()%n+1;
}
The meanings of the arrays are the same as in the statement.
Output Format
Output one line with one integer, representing the maximum experience you can obtain.
2 100000 5 114514
3765807592
Hint
Sample Explanation
In sample , the data are , , .
It is clear that you can either prevent no attack, or prevent the first attack of type , and obtain experience points.
It can be proven that there is no strategy that yields more experience.
Constraints
This problem uses bundled testing with subtasks. The score for each subtask is as follows: | Subtask | | | Score | | :----------: | :----------: | :----------: | :----------: | | | | | | | | | | | | | | | |
For all testdata, it holds that , , 。
Translated by ChatGPT 5