O Those Fads
InterviewTime limit1sMemory limit128 MB
Cows join a fad when its attractiveness L reaches their resistance; each joiner raises L by K. Count the final number of participants.
- Level
Medium4 of 10
- Topics
- Sorting, Greedy, Simulation, Array
- Solved
- No attempts yet
Problem
Like any other teenager, teen cows are occasionally overtaken by fads. Sometimes it's a hula hoop or a pet rock, other times it's Counterstrike, Pokemon, Rick Astley, or tribal tattoos on their udders.
Mathematically, a fad has an initial attractiveness level (). Cow has a resistance () that tells how long she can hold out before joining the fad. When a fad's attractiveness level meets or exceeds a cow's resistance (), that cow wants to participate.
Each cow who participates increases (through peer pressure) the fad's attractiveness by some value (). Because a higher attractiveness can pull in cows with greater resistance, participation happens in a cascade.
Given a population of () cows, determine how many will ultimately participate in the fad.
Input
- Line 1: Three space-separated integers , , and .
- Lines 2 to : Line contains a single integer , the fad resistance of cow .
Output
- Line 1: A single integer, the number of cows that ultimately participate in the fad.