Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace B
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<Int32, Int32> dict = new Dictionary<Int32, Int32>();
- Int32 n = Int32.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- Int32[] input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
- dict[input[0]] = input[1];
- }
- Int32 m = Int32.Parse(Console.ReadLine());
- for (int i = 0; i < m; i++)
- {
- Int32[] input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
- Int32 b = input[0];
- Int32 y = input[1];
- if (!dict.ContainsKey(b))
- {
- dict[b] = y;
- continue;
- }
- if (dict[b] < y)
- dict[b] = y;
- }
- Int64 result = 0;
- foreach (Int32 value in dict.Values)
- {
- result += value;
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement