Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.Design;
- using System.Data;
- using System.Linq;
- using System.Net.Sockets;
- using System.Runtime.InteropServices.ComTypes;
- using System.Threading.Channels;
- using Microsoft.Win32.SafeHandles;
- namespace ConsoleApp6
- {
- class Program
- {
- static void Main(string[] args)
- {
- // read list of integers
- List<int> wagoons = Console.ReadLine().Split().Select(int.Parse).ToList();
- int capacity = int.Parse(Console.ReadLine());
- while (true)
- {
- bool isFull = false;
- List<string> input = Console.ReadLine().Split().ToList();
- if (input[0] == "end")
- {
- break;
- }
- if (input[0] == "Add")
- {
- wagoons.Add(int.Parse(input[1]));
- }
- else
- {
- for (int i = 0; i < wagoons.Count; i++)
- {
- if (wagoons[i] + int.Parse(input[0]) <= capacity)
- {
- wagoons[i] += int.Parse(input[0]);
- }
- }
- }
- }
- Console.WriteLine(String.Join(" ", wagoons));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment