import java.io.*;
import java.util.StringTokenizer;
public class remittance {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int N = Integer.parseInt(r.readLine());
int[] val = new int[N];
for(int i=0; i<N; i++){
StringTokenizer st = new StringTokenizer(r.readLine());
val[i]=Integer.parseInt(st.nextToken())-Integer.parseInt(st.nextToken());
}
//int las=N-1;
int cnt=0;
for(int i=0; i<N; i=(i+1)%N){
if(val[i]<=0){
cnt++;
if(cnt==2*N)
break;
continue;
}
int t = (val[i]+1)/2;
val[i]-=2*t;
val[(i+1)%N]+=t;
cnt=0;
}
boolean w = true;
for(int i=0; i<N; i++)
if(val[i]!=0)
w=false;
if(w)
pw.println("Yes");
else
pw.println("No");
pw.close();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |