[CCC 2015 S3] Gates

Luogu
IDLGP9812
Time1000ms
Memory128MB
DifficultyP3
2015CCC(加拿大)
机场有 $n$ 个登机口,你需要按顺序安排 $m$ 架飞机,第 $i$ 架飞机只能使用 $1 \sim g_{i}$ 号登机口,一个登机口永久只能被一架飞机使用。**当没有登机口可以供某架飞机使用时机场便会关闭,之后的飞机都不能登机。** 请确定一种方案,使得有登机口的飞机数量最多。 ## Input 第一行一个整数 $n$。 第二行一个整数 $m$。 接下来 $m$ 行,每行一个整数 $g_{i}$。 ## Output 一行一个整数,表示最多能安排的飞机数量。 [samples] ## Note **【数据范围】:** 对于 $40\%$ 的数据,$1 \leq n,m \leq 2 \times 10^{3}$。 对于 $100\%$ 的数据,$1 \leq n,m \leq 10^{5}$,$1 \leq g_{i} \leq n$。 本题中 Subtask 0 为原题数据,Subtask 1 为 Hack 数据,Hack 数据不计分。
Samples
Input #1
4
3
4
1
1
Output #1
2
Input #2
4
6
2
2
3
3
4
4
Output #2
3
API Response (JSON)
{
  "problem": {
    "name": "[CCC 2015 S3] Gates",
    "description": {
      "content": "机场有 $n$ 个登机口,你需要按顺序安排 $m$ 架飞机,第 $i$ 架飞机只能使用 $1 \\sim g_{i}$ 号登机口,一个登机口永久只能被一架飞机使用。**当没有登机口可以供某架飞机使用时机场便会关闭,之后的飞机都不能登机。** 请确定一种方案,使得有登机口的飞机数量最多。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 131072
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9812"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "机场有 $n$ 个登机口,你需要按顺序安排 $m$ 架飞机,第 $i$ 架飞机只能使用 $1 \\sim g_{i}$ 号登机口,一个登机口永久只能被一架飞机使用。**当没有登机口可以供某架飞机使用时机场便会关闭,之后的飞机都不能登机。**\n\n请确定一种方案,使得有登机口的飞机数量最多。\n\n## Input\n\n第一行一个整数 $n$。\n\n第二行一个整数 $m$。\n\n接下来 $m$ 行,每行一个整数 ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments