Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _01Hogswatch
- {
- class Program
- {
- static void Main(string[] args)
- {
- int homesToVisit = int.Parse(Console.ReadLine());
- int initalPresents = int.Parse(Console.ReadLine());
- int copyOfInitial = initalPresents;
- int tookInAddition = 0;
- int comeback = 0;
- for (int i = 1; i <= homesToVisit; i++)
- {
- int childPerHouse = int.Parse(Console.ReadLine());
- initalPresents -= childPerHouse;
- if (initalPresents<0)
- {
- comeback++;
- int additionalPresents = Math.Abs(initalPresents);
- initalPresents = 0;
- initalPresents += (copyOfInitial / i) * (homesToVisit - i) + additionalPresents;
- tookInAddition += initalPresents;
- initalPresents -= additionalPresents;
- }
- }
- if (comeback==0)
- {
- Console.WriteLine(initalPresents);
- }
- else
- {
- Console.WriteLine(comeback);
- Console.WriteLine(tookInAddition);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment