Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Numerics;
- namespace Exam_Pr01
- {
- class Program
- {
- static void Main()
- {
- int homesToVisit = int.Parse(Console.ReadLine()); // 1 to 100
- int initialPresents = int.Parse(Console.ReadLine());//1 to 10000
- int presents = initialPresents;
- int returnCounter = 0;
- int presentsShort = 0;
- int totalAdditionalPresents = 0;
- int presentsToTake = 0;
- for (int a = 1; a <= homesToVisit; a++)
- {
- int presentsToLeave = int.Parse(Console.ReadLine());//1 to 100
- if (presents < presentsToLeave)
- {
- presentsShort = Math.Abs(presentsToLeave - presents);//see again
- returnCounter++;
- //({initialPresents} / {visitedHomes}) * {remainingHomes} + {additionalPresents}
- presentsToTake = ((initialPresents / a) * (homesToVisit - a)) + presentsShort;
- presents += presentsToTake;
- totalAdditionalPresents += presentsToTake;
- }
- presents -= presentsToLeave;
- }
- if(returnCounter < 1)
- {
- Console.WriteLine(presents);//read again
- }
- else
- {
- Console.WriteLine("{0}", returnCounter);
- Console.WriteLine(totalAdditionalPresents);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment