#P8666. [蓝桥杯 2018 省 A] 三体攻击
[蓝桥杯 2018 省 A] 三体攻击
Problem Description
The Trisolarans will launch an attack on Earth. To defend against the attack, humans have deployed battleships, arranged in space as a cube with layers, rows, and columns. The battleship in layer , row , column (denoted as battleship ) has health .
The Trisolarans will carry out rounds of “cube attacks”. Each attack deals the same damage to all battleships inside a smaller cuboid region. Specifically, the -th attack is described by parameters .
All battleships satisfying $i\in [la_t, ra_t],j\in [lb_t, rb_t],k\in [lc_t, rc_t]$ will receive damage . If the total accumulated damage on a battleship exceeds its defense (health), then the battleship will explode.
The Earth commander wants you to tell him after which round of attack the first battleship explodes.
Input Format
Read input from standard input.
The first line contains positive integers , , , .
The second line contains integers, where the -th number is .
Lines to : the -th line contains positive integers .
Output Format
Output to standard output.
Output the round number after which the first exploding battleship explodes. It is guaranteed that such a battleship exists.
2 2 2 3
1 1 1 1 1 1 1 1
1 2 1 2 1 1 1
1 1 1 2 1 2 1
1 1 1 1 1 1 2
2
Hint
Sample Explanation
After the -nd round of attack, battleship has received a total of damage, which exceeds its defense and causes it to explode.
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For all testdata, , , , 。
Translated by ChatGPT 5