[PA 2021] Wystawa

Luogu
IDLGP9051
Time6000ms
Memory512MB
DifficultyP6
动态规划 DP贪心二分平衡树2021Special JudgePA(波兰)
给定长度为 $n$ 的序列 $a, b$。 你需要构造一个序列 $c$,构造方法为: - 选择 $k$ 个 $i$,令 $c_i \leftarrow a_i$。 - 对于其他 $i$,令 $c_i \leftarrow b_i$。 求序列 $c$ 的最大子段和的最小值,并给出一种方案。 ## Input 第一行,两个整数 $n, k$; 第二行,$n$ 个整数 $a_1, a_2, \cdots, a_n$; 第三行,$n$ 个整数 $b_1, b_2, \cdots, b_n$。 ## Output 第一行,一个整数,表示序列 $c$ 的最大子段和的最小值; 第二行,一个长为 $n$ 的字符串 $s$,若令 $c_i \leftarrow a_i$,$s_i = \text{A}$;否则,$s_i = \text{B}$。 **如有多解,输出任意一组均可。** [samples] ## Note 对于 $100\%$ 的数据,$1 \leq n \leq 10^5$,$0 \leq k \leq n$,$-10^9 \leq a_i, b_i \leq 10^9$。
Samples
Input #1
6 2
-1 7 0 2 -5 0
3 1 4 -3 -3 12
Output #1
4
BBABBA
Input #2
3 2
-1 -4 -1
-4 -2 -1
Output #2
0
AAB
API Response (JSON)
{
  "problem": {
    "name": "[PA 2021] Wystawa",
    "description": {
      "content": "给定长度为 $n$ 的序列 $a, b$。 你需要构造一个序列 $c$,构造方法为: - 选择 $k$ 个 $i$,令 $c_i \\leftarrow a_i$。 - 对于其他 $i$,令 $c_i \\leftarrow b_i$。 求序列 $c$ 的最大子段和的最小值,并给出一种方案。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 6000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P6"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9051"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定长度为 $n$ 的序列 $a, b$。\n\n你需要构造一个序列 $c$,构造方法为:\n\n- 选择 $k$ 个 $i$,令 $c_i \\leftarrow a_i$。\n- 对于其他 $i$,令 $c_i \\leftarrow b_i$。\n\n求序列 $c$ 的最大子段和的最小值,并给出一种方案。\n\n## Input\n\n第一行,两个整数 $n, k$;\n\n第二行,$n$ 个整数 $a_1, a_2, ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments