Pasta

AtCoder
IDabc241_b
Time2000ms
Memory256MB
Difficulty
There is pasta consisting of $N$ noodles at Takahashi's home. The length of the $i$\-th noodle is $A_i$. Takahashi has a meal plan for the next $M$ days. On the $i$\-th day, he is going to choose a pasta noodle of length exactly $B_i$ and eat it. If no such noodle is available on any day, his plan fails. Additionally, he cannot eat the same noodle on multiple days. Can Takahashi accomplish his meal plan? ## Constraints * $1 \leq M \leq N \leq 1000$ * $1 \leq A_i \leq 10^9$ * $1 \leq B_i \leq 10^9$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $M$ $A_1$ $A_2$ $\ldots$ $A_N$ $B_1$ $B_2$ $\ldots$ $B_M$ [samples]
Samples
Input #1
3 2
1 1 3
3 1
Output #1
Yes

He can eat the $3$\-rd noodle on the $1$\-st day and the $1$\-st noodle on the $2$\-nd day, so his meal plan is feasible.
Input #2
1 1
1000000000
1
Output #2
No

A noodle of length exactly $1$ is needed.
Input #3
5 2
1 2 3 4 5
5 5
Output #3
No

Since there are only $1$ noodle of length $5$, he cannot have a meal on the $2$\-nd day.
API Response (JSON)
{
  "problem": {
    "name": "Pasta",
    "description": {
      "content": "There is pasta consisting of $N$ noodles at Takahashi's home. The length of the $i$\\-th noodle is $A_i$.   Takahashi has a meal plan for the next $M$ days. On the $i$\\-th day, he is going to choose a ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc241_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There is pasta consisting of $N$ noodles at Takahashi's home. The length of the $i$\\-th noodle is $A_i$.  \nTakahashi has a meal plan for the next $M$ days. On the $i$\\-th day, he is going to choose a ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments