【模板】离线二维数点

Luogu
IDLGP10814
Time3000ms
Memory512MB
DifficultyP4
树状数组扫描线离线处理模板题
给你一个长为 $n$ 的序列 $a$,有 $m$ 次询问,每次询问给定 $l,r,x$,求 $[l,r]$ 区间中小于等于 $x$ 的元素个数。 ## Input 第一行两个数 $n,m$。 第二行 $n$ 个数表示序列 $a$。 之后 $m$ 行,每行三个数 $l,r,x$ 表示一次询问。 ## Output 对每个询问,输出一行一个数表示答案。 [samples] ## Background 青蛙。 ## Note 对于 $20\%$ 的数据,满足 $1\le n,m,a_i,l,r,x\le 100$。 对于 $40\%$ 的数据,满足 $1\le n,m,a_i,l,r,x\le 10^4$。 对于 $60\%$ 的数据,满足 $1\le n,m,a_i,l,r,x\le 10^5$。 对于 $80\%$ 的数据,满足 $1\le n,m,a_i,l,r,x\le 10^6$。 对于 $100\%$ 的数据,满足 $1\le n,m,a_i,l,r,x\le 2\times10^6$。
Samples
Input #1
6 4
1 1 4 5 1 4
1 6 3
1 6 4
1 1 4
1 5 4
Output #1
3
5
1
4
API Response (JSON)
{
  "problem": {
    "name": "【模板】离线二维数点",
    "description": {
      "content": "给你一个长为 $n$ 的序列 $a$,有 $m$ 次询问,每次询问给定 $l,r,x$,求 $[l,r]$ 区间中小于等于 $x$ 的元素个数。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P4"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10814"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给你一个长为 $n$ 的序列 $a$,有 $m$ 次询问,每次询问给定 $l,r,x$,求 $[l,r]$ 区间中小于等于 $x$ 的元素个数。\n\n## Input\n\n第一行两个数 $n,m$。\n\n第二行 $n$ 个数表示序列 $a$。\n\n之后 $m$ 行,每行三个数 $l,r,x$ 表示一次询问。\n\n## Output\n\n对每个询问,输出一行一个数表示答案。\n\n[samples]\n\n## Bac...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments