Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- namespace Advanced
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- var cars = new Queue<string>();
- int totalPassed = 0;
- while (input != "end")
- {
- if (input != "green")
- {
- cars.Enqueue(input);
- }
- else
- {
- var carToPass = Math.Min(number, cars.Count);
- for (int i = 0; i < carToPass; i++)
- {
- Console.WriteLine($"{cars.Dequeue()} passed!");
- totalPassed++;
- }
- }
- input = Console.ReadLine();
- }
- Console.WriteLine($"{totalPassed} cars passed the crossroads.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement