forked from igniteeng000/codechef-solution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBANDMATR.java
More file actions
40 lines (40 loc) · 737 Bytes
/
BANDMATR.java
File metadata and controls
40 lines (40 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.io.*;
import java.util.*;
class BANDMATR
{
public static void main(String[] ar)throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
while(t-->0)
{
int n = Integer.parseInt(br.readLine()),c=0,p=n-1;
int[] a = new int[n];
a[0]=n;
for(int i=1;i<n;i++)
{
a[i]=a[i-1]+2*p;
p--;
}
for(int i=0;i<n;i++)
{
String[] s = br.readLine().split(" ");
for(int j=0;j<n;j++)
{
if(Integer.parseInt(s[j])==1)
c++;
}
}
for(int i=0;i<n;i++)
{
if(c<=a[i])
{
out.println(i);
out.flush();
break;
}
}
}
}
}