Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Codechef {
- public static void main(String[] args) {
- try {
- Scanner sc = new Scanner(System.in);
- int[] A = new int[100];
- int T = sc.nextInt();
- int i, j, k;
- for (k = 1; k <= T; k++) {
- int flag = 0;
- int N = sc.nextInt();
- for (i = 1; i <= N; i++) {
- A[i] = sc.nextInt();
- // System.out.print(a[i]+" ");
- }
- outerloop: for (i = 1; i <= N; i++) {
- if (A[i] == 1) {
- for (j = i + 1; j <= i + 5; j++) {
- if (A[j] == 1) {
- // System.out.println("NO");
- flag = 1;
- break outerloop;
- }
- }
- }
- }
- if (flag == 1) {
- System.out.println("NO");
- } else {
- System.out.println("YES");
- }
- }
- } catch (Exception e) {
- return;
- }
- }
- }
Add Comment
Please, Sign In to add comment