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