Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class bus {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int countPassengersBeginning = Integer.parseInt(scanner.nextLine());
- int countStops = Integer.parseInt(scanner.nextLine());
- int newPassengers = 0;
- int totalPassengers = 0;
- for (int i = 1; i <= countStops; i++) {
- int slizashti = Integer.parseInt(scanner.nextLine());
- newPassengers = countPassengersBeginning - slizashti;
- if (i % 2 == 1){
- newPassengers +=2;
- } else if (i % 2 == 0) {
- newPassengers -= 2;
- }
- int kachvashti = Integer.parseInt(scanner.nextLine());
- newPassengers = countPassengersBeginning + kachvashti;
- if (i % 2 == 1){
- newPassengers +=2;
- } else if (i % 2 == 0) {
- newPassengers -= 2;
- }
- }
- System.out.println(newPassengers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement