A. Piles With Stones

Codeforces
IDCF1013A
Time1000ms
Memory256MB
Difficulty
math
English · Original
Chinese · Translation
Formal · Original
There is a beautiful garden of stones in Innopolis. Its most beautiful place is the $n$ piles with stones numbered from $1$ to $n$. EJOI participants have visited this place twice. When they first visited it, the number of stones in piles was $x_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 $y_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 $108$ 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 $n$, the number of piles with stones in the garden ($1 \leq n \leq 50$). The second line contains $n$ integers separated by spaces $x_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 \leq x_i \leq 1000$). The third line contains $n$ integers separated by spaces $y_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 \leq y_i \leq 1000$). ## Output If the records can be consistent output "_Yes_", otherwise output "_No_" (quotes for clarity). [samples] ## 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.
在因诺波利斯有一个美丽的石子花园。 其中最美丽的地方是编号为 $1$ 到 $n$ 的 $n$ 堆石子。 EJOI 参赛者曾两次造访此地。 第一次造访时,各堆石子的数量为 $x_1, x_2, dots.h, x_n$,其中一位参赛者将此序列记录在笔记本中。 第二天他们再次造访,各堆石子的数量变为 $y_1, y_2, dots.h, y_n$,另一位参赛者也将其记录在笔记本中。 众所周知,每位 EJOI 评委在夜间要么待在 108 号房间,要么前往石子处。每位前往石子处的评委要么取走一颗石子,要么将一颗石子从一堆移动到另一堆。我们可以假设有无限多名评委。夜间除了评委外,无人前往石子处。 参赛者想知道他们的记录是否可能正确,还是必定有误。 输入文件的第一行包含一个整数 $n$,表示花园中石子堆的数量($1 lt.eq n lt.eq 50$)。 第二行包含 $n$ 个用空格分隔的整数 $x_1, x_2, dots.h, x_n$,表示参赛者第一次造访石子处时记录的各堆石子数量($0 lt.eq x_i lt.eq 1000$)。 第三行包含 $n$ 个用空格分隔的整数 $y_1, y_2, dots.h, y_n$,表示参赛者第二次造访石子处时记录的各堆石子数量($0 lt.eq y_i lt.eq 1000$)。 如果记录一致,请输出 "_Yes_",否则输出 "_No_"(引号用于清晰说明)。 在第一个示例中,夜间可能发生的情况是:一名评委将第二堆的一颗石子移动到第一堆,另一名评委将第四堆的一颗石子移动到第三堆。 在第二个示例中,评委从第二堆和第四堆取走了石子。 可以证明,评委无法通过移动和取走石子将第一个数组转换为第二个数组。 ## Input 输入文件的第一行包含一个整数 $n$,表示花园中石子堆的数量($1 lt.eq n lt.eq 50$)。第二行包含 $n$ 个用空格分隔的整数 $x_1, x_2, dots.h, x_n$,表示参赛者第一次造访石子处时记录的各堆石子数量($0 lt.eq x_i lt.eq 1000$)。第三行包含 $n$ 个用空格分隔的整数 $y_1, y_2, dots.h, y_n$,表示参赛者第二次造访石子处时记录的各堆石子数量($0 lt.eq y_i lt.eq 1000$)。 ## Output 如果记录一致,请输出 "_Yes_",否则输出 "_No_"(引号用于清晰说明)。 [samples] ## Note 在第一个示例中,夜间可能发生的情况是:一名评委将第二堆的一颗石子移动到第一堆,另一名评委将第四堆的一颗石子移动到第三堆。在第二个示例中,评委从第二堆和第四堆取走了石子。可以证明,评委无法通过移动和取走石子将第一个数组转换为第二个数组。
**Definitions** Let $ n \in \mathbb{Z} $ be the number of piles. Let $ X = (x_1, x_2, \dots, x_n) \in \mathbb{N}^n $ be the initial stone configuration. Let $ Y = (y_1, y_2, \dots, y_n) \in \mathbb{N}^n $ be the final stone configuration. **Constraints** 1. $ 1 \leq n \leq 50 $ 2. $ 0 \leq x_i, y_i \leq 1000 $ for all $ i \in \{1, \dots, n\} $ **Operations Allowed** Each jury member performs exactly one of the following per night: - Remove one stone from a pile (i.e., decrease some $ x_i $ by 1), or - Move one stone from pile $ i $ to pile $ j $ (i.e., decrease $ x_i $ by 1 and increase $ x_j $ by 1, for $ i \ne j $). **Objective** Determine whether there exists a sequence of such operations transforming $ X $ into $ Y $. **Condition for Consistency** The total number of stones is invariant under moves, and may decrease only via removals. Thus, the records are consistent **if and only if**: $$ \sum_{i=1}^n y_i \leq \sum_{i=1}^n x_i $$
Samples
Input #1
5
1 2 3 4 5
2 1 4 3 5
Output #1
Yes
Input #2
5
1 1 1 1 1
1 0 1 0 1
Output #2
Yes
Input #3
3
2 3 9
1 7 9
Output #3
No
API Response (JSON)
{
  "problem": {
    "name": "A. Piles With Stones",
    "description": {
      "content": "There is a beautiful garden of stones in Innopolis. Its most beautiful place is the $n$ piles with stones numbered from $1$ to $n$. EJOI participants have visited this place twice. When they first ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1013A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There is a beautiful garden of stones in Innopolis.\n\nIts most beautiful place is the $n$ piles with stones numbered from $1$ to $n$.\n\nEJOI participants have visited this place twice.\n\nWhen they first ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "在因诺波利斯有一个美丽的石子花园。\n\n其中最美丽的地方是编号为 $1$ 到 $n$ 的 $n$ 堆石子。\n\nEJOI 参赛者曾两次造访此地。\n\n第一次造访时,各堆石子的数量为 $x_1, x_2, dots.h, x_n$,其中一位参赛者将此序列记录在笔记本中。\n\n第二天他们再次造访,各堆石子的数量变为 $y_1, y_2, dots.h, y_n$,另一位参赛者也将其记录在笔记本中。\n\n众所周知...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of piles.  \nLet $ X = (x_1, x_2, \\dots, x_n) \\in \\mathbb{N}^n $ be the initial stone configuration.  \nLet $ Y = (y_1, y_2, \\dots, y_n) \\in \\mat...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments