Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $passengersBeginnig= intval(readline());
- $numberBusStops= intval(readline());
- $countBusStops=0;
- $passengersInBus= $passengersBeginnig;
- while($countBusStops<$numberBusStops){
- $countBusStops++;
- $passengersOut= intval(readline());
- $passengersInBus-=$passengersOut;
- $passengersEnter= intval(readline());
- $passengersInBus+=$passengersEnter;
- if($countBusStops%2==1){
- $passengersInBus+=2;
- }
- if($countBusStops%2==0){
- $passengersInBus-=2;
- }
- }
- echo "The final number of passengers is : $passengersInBus";
Add Comment
Please, Sign In to add comment