#B. 数据结构在压轴

    Type: Default File IO: ds 5000ms 512MiB

数据结构在压轴

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

小 I 并不会出题。小 I 把一些数据结构相关的元素组合在一起便有了这道试题!

题目描述

小 I 给了你长度为 nn 的数列 a1,a2,,ana_1,a_2,\dots,a_n。对 [n][n]2n12^n-1 个子集 SS,计算 f(S)=xSaxf(S)=\sum_{x\in S}a_x,得到 2n12^n-1 个和。

你要求的是这 2n12^n-1 个和的中位数。很不可思议把!

输入格式

本题单点含有多组测试数据。

第一行一个正整数表示 TT

对于每组数据,第一行一个正整数 nn,接下来 nn 个正整数表示 aia_i

输出格式

每组数据,一行一个正整数表示答案。

测试样例

样例输入 样例输出
221 131 2 4 14
见下发 ds/ds2.in 见下发 ds/ds2.ans
见下发 ds/ds3.in 见下发 ds/ds3.ans

样例解释

对于样例 11,第一组测试点 f({1})=1,f({2})=1,f({1,2})=2f(\{1\})=1,f(\{2\})=1,f(\{1,2\})=2,中位数为 22

样例 ds255 个测试点依次满足 1,2,3,4,51,2,3,4,5 的限制。

样例 ds355 个测试点依次满足 6,7,8,9,106,7,8,9,10 的限制(可能不是极限样例)。

数据范围

测试点编号 nn\leq n\sum n\leq aia_i\leq 特殊性质
121\sim2 1515 100100 10001000
353\sim 5 100100 10001000 1010
66 20002000 50005000 10001000 A
787\sim 8 20002000 B
9109\sim 10

对于所有测试点满足 T500T\leq 500

  • 特殊性质 A:对于单个测试点的 aia_i 完全相同。
  • 特殊性质 B:保证单个测试点 ai104\sum a_i\leq 10^4

NOIP模拟赛(一)

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2023-10-23 8:00
End at
2023-10-23 12:00
Duration
4 hour(s)
Host
Partic.
14