veno0

Untitled

Feb 14th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.ComponentModel.Design;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Net.Sockets;
  8. using System.Runtime.InteropServices.ComTypes;
  9. using System.Threading.Channels;
  10. using Microsoft.Win32.SafeHandles;
  11.  
  12. namespace ConsoleApp6
  13. {
  14.     class Program
  15.     {
  16.         static void Main(string[] args)
  17.         {
  18.             // read list of integers
  19.             List<int> wagoons = Console.ReadLine().Split().Select(int.Parse).ToList();
  20.  
  21.             int capacity = int.Parse(Console.ReadLine());
  22.  
  23.             while (true)
  24.             {
  25.                 bool isFull = false;
  26.                 List<string> input = Console.ReadLine().Split().ToList();
  27.                 if (input[0] == "end")
  28.                 {
  29.                     break;
  30.                 }
  31.  
  32.                 if (input[0] == "Add")
  33.                 {
  34.                     wagoons.Add(int.Parse(input[1]));
  35.                 }
  36.                 else
  37.                 {
  38.                     for (int i = 0; i < wagoons.Count; i++)
  39.                     {
  40.                         if (wagoons[i] + int.Parse(input[0]) <= capacity)
  41.                         {
  42.                             wagoons[i] += int.Parse(input[0]);
  43.  
  44.                         }
  45.                        
  46.                        
  47.                     }
  48.                 }
  49.  
  50.                
  51.             }
  52.             Console.WriteLine(String.Join(" ", wagoons));
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment