Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Xml;
- namespace zada4a1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int homes = int.Parse(Console.ReadLine());
- int initialPresents = int.Parse(Console.ReadLine());
- int remainingPressents = initialPresents;
- int usedAdditionalPresents = 0;
- int trips = 0;
- for (int i = 1; i <= homes; i++)
- {
- int neededPresents = int.Parse(Console.ReadLine());
- if (remainingPressents - neededPresents < 0)//когато не стигат подаръците
- {
- int additionalPresents = (initialPresents / i) * (homes - i) + (neededPresents - remainingPressents);
- remainingPressents += additionalPresents;
- usedAdditionalPresents += additionalPresents;
- trips++;
- }
- remainingPressents -= neededPresents;
- }
- if (trips>0)//ако е направил допълнителни разходки
- {
- Console.WriteLine(trips);
- Console.WriteLine(usedAdditionalPresents);
- }
- else
- {
- Console.WriteLine(remainingPressents);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment