Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Loops
- {
- class Program
- {
- static void Main(string[] args)
- {
- int food = int.Parse(Console.ReadLine());
- int days = int.Parse(Console.ReadLine());
- food *= 1000; // grams
- for (int i = 0; i < days; i++)
- {
- int grams = int.Parse(Console.ReadLine());
- food -= grams;
- }
- if (food >= 0)
- {
- Console.WriteLine($"Food is enough! Leftovers: {food} grams.");
- }
- else
- {
- Console.WriteLine($"Food is not enough. You need {-food} grams more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement