CodeForces – 1013A A. Piles With Stones

There is a beautiful garden of stones in Innopolis.

Its most beautiful place is the nn piles with stones numbered from 11 to nn.

EJOI participants have visited this place twice.

When they first visited it, the number of stones in piles was x1,x2,…,xnx1,x2,…,xn, correspondingly. One of the participants wrote down this sequence in a notebook.

They visited it again the following day, and the number of stones in piles was equal to y1,y2,…,yny1,y2,…,yn. One of the participants also wrote it down in a notebook.

It is well known that every member of the EJOI jury during the night either sits in the room 108108 or comes to the place with stones. Each jury member who comes there either takes one stone for himself or moves one stone from one pile to another. We can assume that there is an unlimited number of jury members. No one except the jury goes to the place with stones at night.

Participants want to know whether their notes can be correct or they are sure to have made a mistake.

 

Input

The first line of the input file contains a single integer nn, the number of piles with stones in the garden (1≤n≤501≤n≤50).

The second line contains nn integers separated by spaces x1,x2,…,xnx1,x2,…,xn, the number of stones in piles recorded in the notebook when the participants came to the place with stones for the first time (0≤xi≤10000≤xi≤1000).

The third line contains nn integers separated by spaces y1,y2,…,yny1,y2,…,yn, the number of stones in piles recorded in the notebook when the participants came to the place with stones for the second time (0≤yi≤10000≤yi≤1000).

Output

If the records can be consistent output “Yes”, otherwise output “No” (quotes for clarity).

Examples

input

Copy

5
1 2 3 4 5
2 1 4 3 5

output

Copy

Yes

input

Copy

5
1 1 1 1 1
1 0 1 0 1

output

Copy

Yes

input

Copy

3
2 3 9
1 7 9

output

Copy

No

Note

In the first example, the following could have happened during the night: one of the jury members moved one stone from the second pile to the first pile, and the other jury member moved one stone from the fourth pile to the third pile.

In the second example, the jury took stones from the second and fourth piles.

It can be proved that it is impossible for the jury members to move and took stones to convert the first array into the second array.

题目分析:吐槽!!!!题面看了老半天才看懂。。。明明就是个入门水题。。

有些人两次观察石头,首先,他们在观察石头。对于这么多堆的石头,他们在第二天可以移动石头到另一堆或直接拿走。问他们的观察每堆石头数量的记录是否有问题。如果是移动则总数不变,如果拿走则总数减少,所以第二堆石头一定不可能比第一堆多。所以我们只要比较第一天与第二天的数量之和就可以了,只要第一天的总和大于等于第二天,那么就是对的。

#include<iostream>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
  {
        int sum1=0,sum2=0;
        int a;
        for(int i=0;i<n;i++){
            cin>>a;
            sum1=sum1+a;
        }
        for(int i=0;i<n;i++){
            cin>>a;
            sum2=sum2+a;
        }
        if(sum2<=sum1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值