## GlobeX Cup '19 J2 - Winnie Waifu Wars

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Winnie is playing the latest hot mobile game, AliensXBattle 2. In this game, Winnie has aliens on the field. Each alien starts at level , but can be upgraded by using coins and alien drinks. The maximum level of each alien is . Each alien has a power level. The power level of each alien changes based on level. Help Winnie determine the maximum sum of power levels she can achieve.

#### Input Specification

The first line of input contains two integers and . is the amount of coins Winnie has, and is the amount of alien drinks Winnie has.

The second line of input contains two integers and . is the amount of coins to level up a alien, and is the amount of energy drinks needed to level up a alien.

Each of the next lines of input will contain integers, . represents the power level of the alien at level . It is not guaranteed that a alien will have a power level increases as they level up.

#### Output Specification

Output the maximum power level Winnie can achieve by upgrading her aliens.

#### Constraints

(Hint: What does these constraints tell you about the problem?)

#### Sample Input 1

1 1
1 1
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10

#### Sample Output 1

7