CF1013A.Piles With Stones

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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,…,xnx_1, x_2, \ldots, x_n, 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,…,yny_1, y_2, \ldots, y_n. 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.

在伊诺波利斯有一座美丽的石园。

其中最美丽的地方是编号从 11 到 nn 的 nn 堆石头。

EJOI 参赛者曾两次参观此地。

他们首次参观时,各堆石头的数量依次为 x1,x2,…,xnx_1, x_2, \ldots, x_n。其中一名参赛者将该序列记录在了笔记本中。

次日他们再次参观时,各堆石头的数量变为 y1,y2,…,yny_1, y_2, \ldots, y_n。另一名参赛者也将其记录在了笔记本中。

众所周知,EJOI 评委团的每位成员在夜间要么待在 108 房间,要么前往石园。每位前往石园的评委成员,要么自己取走一颗石头,要么将一颗石头从一堆移动到另一堆。我们可以假设有无限多的评委成员。除评委外,夜间无人前往石园。

参赛者希望知道:他们的笔记是否可能全部正确,还是他们必定犯了错误。

输入格式

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

The second line contains nn integers separated by spaces x1,x2,…,xnx_1, x_2, \ldots, x_n, 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 \leq x_i \leq 1000).

The third line contains nn integers separated by spaces y1,y2,…,yny_1, y_2, \ldots, y_n, 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 \leq y_i \leq 1000).

输入文件的第一行包含一个整数 nn,表示花园中石堆的数量(1≤n≤501 \leq n \leq 50)。

第二行包含 nn 个用空格分隔的整数 x1,x2,…,xnx_1, x_2, \ldots, x_n,表示参与者第一次到达石堆处时笔记本中记录的各石堆的石子数量(0≤xi≤10000 \leq x_i \leq 1000)。

第三行包含 nn 个用空格分隔的整数 y1,y2,…,yny_1, y_2, \ldots, y_n,表示参与者第二次到达石堆处时笔记本中记录的各石堆的石子数量(0≤yi≤10000 \leq y_i \leq 1000)。

输出格式

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

如果记录可以保持一致,则输出“Yes”,否则输出“No”(引号仅用于明确显示)。

输入输出样例

  • 输入#1

    5
    1 2 3 4 5
    2 1 4 3 5

    输出#1

    Yes
  • 输入#2

    5
    1 1 1 1 1
    1 0 1 0 1

    输出#2

    Yes
  • 输入#3

    3
    2 3 9
    1 7 9

    输出#3

    No

说明/提示

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.

在第一个例子中,夜间可能发生的情况如下:一名评委将第二堆石子中的一颗石子移至第一堆,另一名评委将第四堆石子中的一颗石子移至第三堆。

在第二个例子中,评委从第二堆和第四堆取走了石子。

可以证明,评委无法通过移动和取走石子的方式将第一个数组转换为第二个数组。

输入解题思路,AI测评打分。不知道怎么写?

首页