CF1792A.GamingForces

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

GamingForces

Monocarp is playing a computer game. He's going to kill nn monsters, the ii-th of them has hih_i health.

Monocarp's character has two spells, either of which he can cast an arbitrary number of times (possibly, zero) and in an arbitrary order:

  • choose exactly two alive monsters and decrease their health by 11;
  • choose a single monster and kill it.

When a monster's health becomes 00, it dies.

What's the minimum number of spell casts Monocarp should perform in order to kill all monsters?

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains a single integer nn (1n1001 \le n \le 100) — the number of monsters.

The second line contains nn integers h1,h2,,hnh_1, h_2, \dots, h_n (1hi1001 \le h_i \le 100) — the health of each monster.

The sum of nn over all testcases doesn't exceed 21042 \cdot 10^4.

Output

For each testcase, print a single integer — the minimum number of spell casts Monocarp should perform in order to kill all monsters.

Note

In the first testcase, the initial health list is [1,2,1,2][1, 2, 1, 2]. Three spells are casted:

  • the first spell on monsters 11 and 22 — monster 11 dies, monster 22 has now health 11, new health list is [0,1,1,2][0, 1, 1, 2];
  • the first spell on monsters 33 and 44 — monster 33 dies, monster 44 has now health 11, new health list is [0,1,0,1][0, 1, 0, 1];
  • the first spell on monsters 22 and 44 — both monsters 22 and 44 die.

In the second testcase, the initial health list is [2,4,2][2, 4, 2]. Three spells are casted:

  • the first spell on monsters 11 and 33 — both monsters have health 11 now, new health list is [1,4,1][1, 4, 1];
  • the second spell on monster 22 — monster 22 dies, new health list is [1,0,1][1, 0, 1];
  • the first spell on monsters 11 and 33 — both monsters 11 and 33 die.

In the third testcase, the initial health list is [1,2,3,4,5][1, 2, 3, 4, 5]. Five spells are casted. The ii-th of them kills the ii-th monster with the second spell. Health list sequence: [1,2,3,4,5][1, 2, 3, 4, 5] \rightarrow [0,2,3,4,5][0, 2, 3, 4, 5] \rightarrow [0,0,3,4,5][0, 0, 3, 4, 5] \rightarrow [0,0,0,4,5][0, 0, 0, 4, 5] \rightarrow [0,0,0,0,5][0, 0, 0, 0, 5] \rightarrow [0,0,0,0,0][0, 0, 0, 0, 0].

Samples

3
4
1 2 1 2
3
2 4 2
5
1 2 3 4 5
3
3
5

在线编程 IDE

建议全屏模式获得最佳体验