You are viewing a single comment's thread. Return to all comments →
//MY SOLUTION
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int B[] = new int[N]; int count=0; boolean flag=true; for(int B_i=0; B_i < N; B_i++) { B[B_i] = in.nextInt(); } for(int i=0;i<N;i++) { if(B[i]%2!=0) { B[i]++; count++; if(i==0) { B[i+1]++; count++; } else if(i==(N-1)) { B[i-1]++; count++; } else { B[i+1]++; count++; } } } for(int i=0;i<N;i++) { if(B[i]%2!=0) { flag=false; } } if(flag) System.out.println(count); else System.out.println("NO"); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
//MY SOLUTION
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}