[PA 2021] Sumy

Luogu
IDLGP9050
Time1000ms
Memory512MB
DifficultyP3
贪心二分2021排序前缀和PA(波兰)
有 $n$ 条鱼,其中第 $i$ 条的质量为 $a_i$ 克。 $x$ 能吃掉 $y$ 当且仅当 $a_x > a_y$。 若 $x$ 吃了 $y$,$y$ 会消失,$a_x$ 会变为 $a_x + a_y$。 你可以随意指定吃鱼的顺序,直至留下一条鱼为止。 求每一条鱼是否可能被作为最后**唯一**的鱼留下。**若最终无法只剩下一条鱼,则每条鱼均不满足此条件。** ## Input 第一行,一个整数 $n$; 第二行,$n$ 个整数 $a_1, a_2, \cdots, a_n$。 ## Output 一行,一个长度为 $n$ 的字符串 $s$,其中 $s_i = \text{T}$ 表示第 $i$ 条鱼满足上述条件,$s_i = \text{N}$ 表示第 $i$ 条鱼不满足上述条件。 [samples] ## Note #### 样例 #1 解释 下面用 $x \rightarrow y$ 表示 $x$ 吃 $y$。 留下 $2$ 号鱼的一种方案如下:$2 \rightarrow 1, 2 \rightarrow 3, 2 \rightarrow 4, 2 \rightarrow 5, 2 \rightarrow 6$。 #### 数据范围 对于 $100\%$ 的数据,$1 \leq n \leq 5 \times 10^5$,$1 \leq a_i \leq 10^9$。
Samples
Input #1
6
2 7 1 8 2 8
Output #1
NTNTNT
Input #2
3
5 4 4
Output #2
TNN
API Response (JSON)
{
  "problem": {
    "name": "[PA 2021] Sumy",
    "description": {
      "content": "有 $n$ 条鱼,其中第 $i$ 条的质量为 $a_i$ 克。 $x$ 能吃掉 $y$ 当且仅当 $a_x > a_y$。 若 $x$ 吃了 $y$,$y$ 会消失,$a_x$ 会变为 $a_x + a_y$。 你可以随意指定吃鱼的顺序,直至留下一条鱼为止。 求每一条鱼是否可能被作为最后**唯一**的鱼留下。**若最终无法只剩下一条鱼,则每条鱼均不满足此条件。**",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9050"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "有 $n$ 条鱼,其中第 $i$ 条的质量为 $a_i$ 克。\n\n$x$ 能吃掉 $y$ 当且仅当 $a_x > a_y$。\n\n若 $x$ 吃了 $y$,$y$ 会消失,$a_x$ 会变为 $a_x + a_y$。\n\n你可以随意指定吃鱼的顺序,直至留下一条鱼为止。\n\n求每一条鱼是否可能被作为最后**唯一**的鱼留下。**若最终无法只剩下一条鱼,则每条鱼均不满足此条件。**\n\n## Input\n\n第...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments