Stomping Cats
InterviewTime limit2sMemory limit512 MB
Given cat counts per apartment in an n by m building, sum the fine a for every apartment whose upstairs neighbor has more than twice its cats.
- Level
Easy2 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
In a certain city, people kept complaining that they could not sleep. Every day, a large pile of complaints about certain people being too loud at night piled up at the relevant officials' office. Something had to be done. So at the next meeting, it was decided to pass a law banning loud noises after eleven o'clock at night.
Following bureaucratic tradition, the law had to spell out the concept of <>. After discussion, it was decided to ban, for example, playing musical instruments, moving furniture, and hammering nails at night.
Just as the law was about to be passed, one deputy noted that a refrigerator is not furniture, so moving it did not fall under the law. Other deputies also began to come up with additional prohibitions that had not originally been in the law. As a result, nighttime moans, creaks, dog barks, and the stomping of cats were banned.
A fine of rubles was introduced for violating the law.
Upon learning of the law, Petya decided to find out what fine could be imposed on the residents of his building. The building where Petya lives has floors, and each floor has apartments. The apartments are numbered from 1 to . If apartment number is on some floor that is not the top floor, then the apartment directly above it is number .
It is known that cats live in the -th apartment. Petya assumed that the residents of an apartment will complain about the neighbors above only if the cats above stomp substantially louder than their own. After conducting experiments, Petya decided that cats stomp substantially louder than cats if .
Find the total fine the residents of this building will have to pay if everyone whose cats in the apartment directly above stomp substantially louder than their own cats complains about their upstairs neighbors and those neighbors are fined.
Input
The first line of the input file contains three integers , , : the number of floors, the number of apartments on each floor, and the fine amount (, , ). The next line contains integers , where is the number of cats in the -th apartment ().
Output
Print the total fine.
Hint
In the example, only the residents of apartment 6 have to pay the fine.