Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- public class Program
- {
- public static void Main()
- {
- List<int>first = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int>second = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> limits = new List<int>();
- List<int>result = new List<int>();
- if (first.Count > second.Count)
- {
- limits.Add(first[first.Count-2]);
- limits.Add(first[first.Count-1]);
- first.RemoveRange(first.Count-2,2);
- second.Reverse();
- for (int i=0; i<first.Count; i++)
- {
- result.Add(first[i]);
- result.Add(second[i]);
- }
- int constr1 = limits[0];
- int constr2 = limits[1];
- int minConstr = Math.Min(constr1,constr2);
- int maxConstr = Math.Max(constr1,constr2);
- List<int>answer = new List<int>();
- for (int i=0; i<result.Count; i++)
- {
- int currNum = result[i];
- if (currNum>minConstr && currNum<maxConstr)
- {
- answer.Add(currNum);
- }
- }
- answer.Sort();
- Console.WriteLine(string.Join(" ",answer));
- }
- else
- {
- limits.Add(second[0]);
- limits.Add(second[1]);
- second.RemoveRange(0,2);
- second.Reverse();
- for (int i=0; i<first.Count; i++)
- {
- result.Add(first[i]);
- result.Add(second[i]);
- }
- int constr1 = limits[0];
- int constr2 = limits[1];
- int minConstr = Math.Min(constr1,constr2);
- int maxConstr = Math.Max(constr1,constr2);
- List<int>answer = new List<int>();
- for (int i=0; i<result.Count; i++)
- {
- int currNum = result[i];
- if (currNum>minConstr && currNum<maxConstr)
- {
- answer.Add(currNum);
- }
- }
- answer.Sort();
- Console.WriteLine(string.Join(" ",answer));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement