[ROI 2018] Innophone

Luogu
IDLGP9288
Time3000ms
Memory512MB
DifficultyP7
2018线段树分块凸包扫描线ROI(俄罗斯)
有一个二元函数 $f(x,y)$,它是这么定义的: $f(x,y)=\left\{ \begin{array}{rcl} a, & & {\text{if} \quad \quad \ \ \ a \leq x}\\ b, & & {\text{else if} \quad b \leq y}\\ 0, & & {\text{else}} \end{array} \right.$ 其中 $a,b$ 为常数。现在给定 $n$ 组 $x,y$,你需要选择合适的 $a,b$,使得 $\sum_{i=1}^{n} f(x_i,y_i)$ 最大。 ## Input 第一行一个整数 $n$,表示 $x$,$y$ 的组数。 后面 $n$ 行,每行两个数 $x_i$,$y_i$。 ## Output 一行,一个数,输出 $\max(\sum_{i=1}^{n} f(x_i,y_i))$。 [samples] ## Background 译自 [ROI 2018 Day1](https://neerc.ifmo.ru/school/archive/2017-2018.html) T3. [Иннофон](https://neerc.ifmo.ru/school/archive/2017-2018/ru-olymp-roi-2018-day1.pdf) ([Innophone](http://codeforces.com/gym/102147/problem/B))。 ## Note 对于 $100\%$ 的数据,$0\leq y_i\leq x_i\leq 10^9$,$1 \leq n \leq 1.5 \times 10^5$。 | 子任务编号 | $n$ | $x,y$ | | :----------: | :----------: | :----------: | | $1$ | $1 \leq n \leq 100$ | $0 \leq y_i \leq x_i \leq 100$ | | $2$ | $1 \leq n \leq 300$ | $0\leq y_i\leq x_i\leq 10^9$ | | $3$ | $1 \leq n \leq 3000$ | $0\leq y_i\leq x_i\leq 10^9$ | | $4$ | $1 \leq n \leq 10^5$ | $y_i = 0$ | | $5$ | $1 \leq n \leq 10^5$ | $x_i = y_i$ | | $6$ | $1 \leq n \leq 50000$ | $0\leq y_i\leq x_i\leq 10^9$ | | $7$ | $1 \leq n \leq 75000$ | $0\leq y_i\leq x_i\leq 10^9$ | | $8$ | $1 \leq n \leq 10^5$ | $0\leq y_i\leq x_i\leq 10^9$ | | $9$ | $1 \leq n \leq 1.25 \times 10^5$ | $0\leq y_i\leq x_i\leq 10^9$ | | $10$ | $1 \leq n \leq 1.5 \times 10^5$ | $0\leq y_i\leq x_i\leq 10^9$ |
Samples
Input #1
5
80 20
60 50
40 40
15 10
70 30
Output #1
220
Input #2
1
50 0
Output #2
50
API Response (JSON)
{
  "problem": {
    "name": "[ROI 2018] Innophone",
    "description": {
      "content": "有一个二元函数 $f(x,y)$,它是这么定义的:  $f(x,y)=\\left\\{ \\begin{array}{rcl} a, & & {\\text{if} \\quad \\quad \\ \\ \\ a \\leq x}\\\\ b, & & {\\text{else if} \\quad b \\leq y}\\\\ 0, & & {\\text{else}} \\end{array} \\right.$ 其中 $a",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P7"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9288"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "有一个二元函数 $f(x,y)$,它是这么定义的:\n\n $f(x,y)=\\left\\{\n\\begin{array}{rcl}\na, & & {\\text{if} \\quad \\quad \\ \\ \\ a \\leq x}\\\\\nb, & & {\\text{else if} \\quad b \\leq y}\\\\\n0, & & {\\text{else}}\n\\end{array} \\right.$\n\n其中 $a...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments