Skip to content

Instantly share code, notes, and snippets.

@modos
Created September 26, 2022 22:07
Show Gist options
  • Save modos/53eb1034dcbf14bec31ea8f43155b050 to your computer and use it in GitHub Desktop.
Save modos/53eb1034dcbf14bec31ea8f43155b050 to your computer and use it in GitHub Desktop.
اسنپ در شکرستان
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[][] array = new int[n][n];
for(int i=0; i< n; i++) {
for(int j=0; j<n; j++) {
array[i][j] = scanner.nextInt();
}
}
int sum = 0;
for(int x=0; x < m; x++) {
int x1 = scanner.nextInt();
int y1 = scanner.nextInt();
sum = sum + array[x1-1][y1-1];
}
System.out.print(sum);
scanner.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment