Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- class Program
- {
- static void Main()
- {
- int size = int.Parse(Console.ReadLine());
- int[][] n = new int[size][];
- for (int i = 0; i < size; i++)
- {
- n[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
- }
- int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
- long sum = n[0][d[0]];
- for (int i = 0; i < d.Length-1; i++)
- {
- sum += n[d[i]][d[i + 1]];
- }
- Console.WriteLine(sum);
- }
- }
Add Comment
Please, Sign In to add comment