Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

You are given two integer sequences of length N: a1,a2,..,aN and b1,b2,..,bN. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.

Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:

  • Add 2 to ai.
  • Add 1 to bj.

Constraints

  • 1≤N≤10 000
  • 0≤ai,bi≤109 (1≤iN)
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

N
a1 a2 .. aN
b1 b2 .. bN

Output

If we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.


Sample Input 1

Copy
3
1 2 3
5 2 2

Sample Output 1

Copy
Yes

For example, we can perform three operations as follows to do our job:

  • First operation: i=1 and j=2. Now we have a={3,2,3}, b={5,3,2}.
  • Second operation: i=1 and j=2. Now we have a={5,2,3}, b={5,4,2}.
  • Third operation: i=2 and j=3. Now we have a={5,4,3}, b={5,4,3}.

Sample Input 2

Copy
5
3 1 4 1 5
2 7 1 8 2

Sample Output 2

Copy
No

Sample Input 3

Copy
5
2 7 1 8 2
3 1 4 1 5

Sample Output 3

Copy
No

如果a[i]>b[i],就需要a[i]-b[i]个b[i] + 1 操作,如果a[i] < b[i],就需要(a[i] - b[i])/2个a[i] + 2操作与其他的b[j] + 1操作进行组合,比如a[i] = 1,b[i] = 6,就需要2个第二种操作,加完后a[i]为5,比6差1,只需要a[i],b[i]同时再做一个操作就可以。根据题意需要第二个操作不少于第一个操作,才能保证两个操作一齐进行。
代码:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int n;
long long a[10000],b[10000];
long long z,f;
int main()
{
    cin>>n;
    for(int i = 0;i < n;i ++)
    {
        cin>>a[i];
    }
    for(int i = 0;i < n;i ++)
    {
        cin>>b[i];
        if(b[i] - a[i] < 0)f += a[i] - b[i];
        else if(b[i] - a[i] > 0)z += (b[i] - a[i]) / 2;
    }
    if(z >= f)cout<<"Yes";
    else cout<<"No";
}