Advertisement
Guest User

Untitled

a guest
Oct 9th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. public static void main(String[] args) {
  2.         Scanner sc=new Scanner(System.in);
  3.         int n=sc.nextInt();
  4.         boolean w=false;
  5.         int[] mass=new int[n];
  6.         for(int i=0;i<n;i++){
  7.             mass[i]=sc.nextInt();
  8.            
  9.         }
  10.         int j=0, r=0;
  11.         for(int i=1;i<n;i++){
  12.             while(mass[i]==mass[j]){
  13.                 if(j==0)r=i;
  14.                 if(j==r-1 && i==n-1){w=true; break;}
  15.                 i++;
  16.                 j++;
  17.                 if(i>=n)break;
  18.             }
  19.         }
  20.         System.out.println(w);
  21.         sc.close();
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement