Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp1
- {
- class Program
- {
- public static void Main(string[] args)
- {
- int n, k;
- var inputnk = Console.ReadLine();
- if (inputnk == null) return;
- n = Convert.ToInt32(inputnk.Split(" ")[0]);
- k = Convert.ToInt32(inputnk.Split(" ")[1]);
- var inputA = Console.ReadLine();
- if (inputA == null) return;
- HashSet<int> maxANumbers = new HashSet<int>(n);
- var maxA = 0;
- var masA = inputA.Split(" ");
- for (int i = 0; i < n; i++)
- {
- int a = Convert.ToInt32(masA[i]);
- if (a == maxA)
- {
- maxANumbers.Add(i + 1);
- }
- if (a > maxA)
- {
- maxANumbers.Clear();
- maxA = a;
- maxANumbers.Add(i + 1);
- }
- }
- var inputB = Console.ReadLine();
- if (inputB == null) return;
- var masB = inputB.Split(" ");
- for (int i = 0; i < k; i++)
- {
- int b = Convert.ToInt32(masB[i]);
- if (maxANumbers.Contains(b))
- {
- maxANumbers.Remove(b);
- }
- }
- if (maxANumbers.Count > 0)
- {
- Console.WriteLine("Yes");
- }
- else
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment