Buildings

来源:互联网 发布:铃声制作软件 编辑:程序博客网 时间:2024/05/01 22:09
Sample Input
2
2 2
1 1
0 0
3 3
1 0 1
0 0 1
1 1 0
Sample Output
2

5


import java.io.*;
import java.util.*;
public class PracticeIV {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
while((a--)>0){
int n = sc.nextInt();
int m = sc.nextInt();
int[][] b = new int[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
b[i][j] = sc.nextInt();
}
}
int count = 0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(b[i][j]==1)
count++;
}
}
System.out.println(count);
}
}
}

我这代码一直报:Memory Limit Exceeded  

0 0
原创粉丝点击