Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Ransom Note
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Collections; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here string[] tokens_m = Console.ReadLine().Split(' '); int m = Convert.ToInt32(tokens_m[0]); int n = Convert.ToInt32(tokens_m[1]); string[] magazine = Console.ReadLine().Split(' '); string[] ransom = Console.ReadLine().Split(' '); Dictionary<string,int> mag = new Dictionary<string,int>(); Dictionary<string,int> note = new Dictionary<string,int>(); mag = ConvertArray(magazine); note = ConvertArray(ransom); bool result = true; foreach(KeyValuePair<string,int> item in note){ if(!mag.Contains(item)){ if(mag.ContainsKey(item.Key) && mag[item.Key] < item.Value) result = false; } } if(result == true){ Console.WriteLine("Yes"); }else{ Console.WriteLine("No"); } //end code } static private Dictionary<string,int> ConvertArray(string[] arr){ Dictionary<string,int> dic = new Dictionary<string,int>(); foreach(string word in arr){ if(dic.ContainsKey(word)){ dic[word]++; }else{ dic.Add(word,1); } } return dic; } } }
run
|
edit
|
history
|
help
0
work_laba#2
hhhh
test1.m
s
sdfghyjuki54efc sacd
Rand things kurs 8 network
changeMe
mnnjhjhjbhjb
Recursion
Planet-D v.0.6