Здравейте, искам да попитам относно задачата Автобус от вчерашния примерен изпит
Условие: https://softuni.bg/downloads/svn/programming-basics/2018-02/Exam/Problem%2004%20-%20Bus.pdf
Задачата я реших 100/100, но се мъчих много и не мисля, че решението ми е добро.
Ако някой знае по-добро решение моля да го даде.
Ето моя код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programming_basics
{
    class Program
    {
        static void Main(string[] args)
        {
            int people = int.Parse(Console.ReadLine());
            int stops = int.Parse(Console.ReadLine());
            int total = 0;
            int totalPeople = 0;
            int i = 0;
            for (i = 1; i <= stops; i++)
            {
                int getOutOfTheBus = int.Parse(Console.ReadLine());
                int getInTheBus = int.Parse(Console.ReadLine());
                if (i < 3)
                {
                    if (i % 2 != 0)
                    {
                        total += people - getOutOfTheBus + getInTheBus + 2;
                    }
                    else
                    {
                        total = total - getOutOfTheBus - 2 + getInTheBus;
                    }
                }
                else if (i == 3)
                {
                    if (i % 2 != 0)
                    {
                        totalPeople = total - getOutOfTheBus + getInTheBus + 2;
                    }
                    else
                    {
                        totalPeople = total - getOutOfTheBus - 2 + getInTheBus;
                    }
                }
                else if (i > 3)
                {
                    if (i % 2 != 0)
                    {
                        totalPeople = totalPeople - getOutOfTheBus + getInTheBus + 2;
                    }
                    else
                    {
                        totalPeople = totalPeople - getOutOfTheBus - 2 + getInTheBus;
                    }
                }
            }
            if (i < 4)
            {
                Console.WriteLine($"The final number of passengers is : {total}");
            }
            else
            {
                Console.WriteLine($"The final number of passengers is : {totalPeople}");
            }
        }
    }
}
Мерси. Решението ти от вчера е много по-добро от моето.