fork download
  1. using System.Numerics;
  2. using static IO;
  3. public class IO
  4. {
  5. public static IO Cin = new();
  6. public static StreamReader reader = new(Console.OpenStandardInput());
  7. public static StreamWriter writer = new(Console.OpenStandardOutput());
  8. public static implicit operator string(IO _) => reader.ReadLine();
  9. public static implicit operator char[](IO _) => reader.ReadLine().ToArray();
  10. public static implicit operator int(IO _) => int.Parse(reader.ReadLine());
  11. public static implicit operator double(IO _) => double.Parse(reader.ReadLine());
  12. public static implicit operator string[](IO _) => reader.ReadLine().Split();
  13. public static implicit operator int[](IO _) => Array.ConvertAll(reader.ReadLine().Split(), int.Parse);
  14. public void Deconstruct(out int a, out int b) { int[] r = Cin; (a, b) = (r[0], r[1]); }
  15. public void Deconstruct(out int a, out int b, out int c) { int[] r = Cin; (a, b, c) = (r[0], r[1], r[2]); }
  16. public static void Loop(int end, Action<int> action, int start = 0, in int add = 1) { for (; start < end; start += add) action(start); }
  17. public static object? Cout { set { writer.Write(value); } }
  18. public static object? Coutln { set { writer.WriteLine(value); } }
  19. public static void Main() { Program.Coding(); writer.Flush(); }
  20. }
  21. class Program
  22. {
  23. public static void Coding()
  24. {
  25. checked
  26. {
  27. int n = Cin;
  28. Queue<int> myCards = new(((int[])Cin).OrderBy(x => -x));
  29. Queue<int> otherCards = new(((int[])Cin).OrderBy(x => -x));
  30.  
  31. int maxScore = 0;
  32. while (myCards.Count > 0)
  33. {
  34. int me = myCards.Dequeue();
  35. if (otherCards.Peek() > me)
  36. {
  37. maxScore++;
  38. otherCards.Dequeue();
  39. }
  40. }
  41.  
  42. Cout = maxScore < (n + 1) / 2 ? "NO" : "YES";
  43. }
  44. }
  45. }
Success #stdin #stdout 0.09s 31720KB
stdin
5
2 1 3 5 6
1 1 3 2 5
stdout
YES