Skip to content

Instantly share code, notes, and snippets.

@yssharma
Last active October 16, 2016 12:09
Show Gist options
  • Save yssharma/f6953300aef28d8dcbea4823300f2930 to your computer and use it in GitHub Desktop.
Save yssharma/f6953300aef28d8dcbea4823300f2930 to your computer and use it in GitHub Desktop.
Codeforces 376 Div 2
package codeforces.x376;
import java.util.Scanner;
/**
* Created by ysharma on 10/16/16.
*/
public class B {
public static void main(String[] args) {
new B().doit();
}
private void doit(){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N];
for(int i=0; i<N; i++){
a[i] = sc.nextInt();
}
for(int i=0; i<N; i++){
a[i] = a[i] % 2; // buy all 2 pizzas
if(a[i] == 1){
if(i == N-1){
System.out.println("NO");
return;
} else {
a[i] = 0;
a[i+1] = a[i+1] - 1;
}
}
}
for(int i : a){
if(a[i] != 0){ // change this to : if(i != 0){
System.out.println("NO");
return;
}
}
System.out.println("YES");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment