Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int n, m;
- scanf("%d%d", &n, &m);
- int mat[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &mat[i][j]);
- }
- }
- int k;
- scanf("%d", &k);
- int sum = 0, brojac = 0;
- for(int i = 0; i < k; i++) {
- int x, y;
- scanf("%d%d", &x, &y);
- if(x >= 0 && x < n && y >= 0 && y < m) {
- sum += mat[x][y];
- brojac++;
- }
- }
- printf("%d\n", sum / brojac);
- return 0;
- }
- /*
- 4 5
- 1 2 5 0
- 7 2 3 1
- 12 0 5 4
- 6 1 0 1
- 2 3 4 5
- 4
- 1 2
- 0 4
- 5 1
- 2 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement