#K51902. Minimal Attempts
Minimal Attempts
Minimal Attempts
You are given m levels where each level has two challenges: a number of monsters and a number of coins. For each level i (where i = 1, 2, \dots, m), you are provided with:
- An initial strength requirement \(S_i\) (not used in the calculation),
- An initial agility requirement \(A_i\) (not used in the calculation),
- The number of monsters \(M_i\), and
- The number of coins \(C_i\).
To pass a level, you must overcome the maximum challenge among monsters and coins, i.e., the minimal number of attempts required for level \(i\) is \(\max(M_i, C_i)\). The overall result is the maximum of these values over all levels.
Your task is to compute and output the minimal number of attempts required in the worst-case scenario to pass all levels.
inputFormat
The input is given via standard input and has the following format:
m S1 S2 ... Sm A1 A2 ... Am M1 M2 ... Mm C1 C2 ... Cm
Here, m is the number of levels. The following four lines contain m space-separated integers each, representing the lists \(S\), \(A\), \(M\), and \(C\) respectively.
outputFormat
Output via standard output a single integer representing the minimal number of attempts required to pass all levels. This number is given by:
[ \text{answer} = \max_{1 \leq i \leq m} \big(\max(M_i, C_i)\big) ]## sample
2
10 15
20 25
3 2
4 5
5