Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace exampreparation
- {
- class Program
- {
- static void Main(string[] args)
- {
- int voucher = int.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- int price = 0;
- int movieCounter = 0;
- int foodCounter = 0;
- while (input != "End")
- {
- if (input.Length > 8)
- {
- price = input[0] + input[1];
- if (price <= voucher)
- {
- voucher -= price;
- }
- else
- {
- break;
- }
- movieCounter++;
- }
- else
- {
- price = input[0];
- if (price <= voucher)
- {
- voucher -= price;
- }
- else
- {
- break;
- }
- foodCounter++;
- }
- input = Console.ReadLine();
- }
- if (input == "End" || price > voucher)
- {
- Console.WriteLine($"{movieCounter}");
- Console.WriteLine($"{foodCounter}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement