[JRKSJ R5] 1-1 A

Luogu
IDLGP8847
Time1000ms
Memory128MB
DifficultyP2
2022洛谷原创Special Judge构造洛谷月赛
给出一个序列 $a$,$\forall i\in [1,n],a_i\in \{1,-1\}$。 你可以将序列任意重排,需最小化重排后序列的最大子段和。 ## Input 第一行一个整数 $n$。 第二行 $n$ 个整数表示 $a$。 ## Output 一行 $n$ 个整数,以空格隔开,表示重排后的序列。 若有多解,则任意输出一个答案即可。 [samples] ## Background 本题是 1-1 的较易版本,较难版本为 [1-1 B](https://www.luogu.com.cn/problem/P8848)。 ## Note 最大子段和的定义:序列中一段区间的和的最大值。即 $\max_{1\le l\le r\le n} \sum_{i=l}^r a_i$。 本题使用 $\text{Special Judge}$,只要你的输出满足题意即可通过。 **本题输入输出文件较大,请使用恰当的输入输出方式。** ### 数据规模 本题采用捆绑测试。 | $\text{Subtask}$ | $n\le$ | $\text{Score}$ | | :----------: | :----------: | :----------: | | $1$ | $10$ | $40$ | | $2$ | $10^6$ | $60$ | 对于 $100\%$ 的数据,$1\le n\le 10^6$,$a_i\in \{1,-1\}$。
Samples
Input #1
4
1 1 -1 -1
Output #1
1 -1 -1 1
API Response (JSON)
{
  "problem": {
    "name": "[JRKSJ R5] 1-1 A",
    "description": {
      "content": "给出一个序列 $a$,$\\forall i\\in [1,n],a_i\\in \\{1,-1\\}$。 你可以将序列任意重排,需最小化重排后序列的最大子段和。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 131072
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP8847"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给出一个序列 $a$,$\\forall i\\in [1,n],a_i\\in \\{1,-1\\}$。\n\n你可以将序列任意重排,需最小化重排后序列的最大子段和。\n\n## Input\n\n第一行一个整数 $n$。\n\n第二行 $n$ 个整数表示 $a$。\n\n## Output\n\n一行 $n$ 个整数,以空格隔开,表示重排后的序列。\n\n若有多解,则任意输出一个答案即可。\n\n[samples]\n\n## Backg...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments