五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 1767B - Block Towers

2023-07-05 10:04 作者:您是打尖兒還是住店呢  | 我要投稿

There are n block towers, numbered from 1 to n. The i-th tower consists of ai blocks.

In one move, you can move one block from tower i to tower j, but only if ai>aj. That move increases aj by 1 and decreases ai by 1. You can perform as many moves as you would like (possibly, zero).

What's the largest amount of blocks you can have on the tower 1 after the moves?

Input

The first line contains a single integer t (1≤t≤104) — the number of testcases.

The first line of each testcase contains a single integer n (2≤n≤2?105) — the number of towers.

The second line contains n integers a1,a2,…,an (1≤ai≤109) — the number of blocks on each tower.


The sum of n over all testcases doesn't exceed 2?105.


Output

For each testcase, print the largest amount of blocks you can have on the tower 1 after you make any number of moves (possibly, zero).

-------------------------------------------------------------

有n座塔樓,編號(hào)從1到n。 第 i 座塔由 ai 塊組成。

一次移動(dòng),您可以將一個(gè)方塊從 i 塔移動(dòng)到 j 塔,但前提是 ai>aj。 該移動(dòng)使 aj 增加 1,并將 ai 減少 1。您可以執(zhí)行任意數(shù)量的移動(dòng)(可能是零)。

移動(dòng)后 1 號(hào)塔上最多可以擁有多少塊方塊?

輸入

第一行包含一個(gè)整數(shù) t (1≤t≤104) — 測(cè)試用例的數(shù)量。

每個(gè)測(cè)試用例的第一行包含一個(gè)整數(shù) n (2≤n≤2?105) — 塔的數(shù)量。

第二行包含 n 個(gè)整數(shù) a1,a2,…,an (1≤ai≤109) — 每個(gè)塔上的塊數(shù)。


所有測(cè)試用例的 n 總和不超過 2?105。


輸出

對(duì)于每個(gè)測(cè)試用例,在進(jìn)行任意次數(shù)的移動(dòng)(可能為零)后,打印塔 1 上可以擁有的最大塊數(shù)。

----------------------------

只要先找跟a1最接近的值,然后把a(bǔ)1增加后,在繼續(xù)找,所以這里面可以用排序解決,但是我用數(shù)組排序,提交后,超時(shí)了。。。沒辦法就只能有優(yōu)先隊(duì)列了。還好通過了。。

下面是代碼:


CF 1767B - Block Towers的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
成都市| 会同县| 临安市| 蓬莱市| 海兴县| 芦溪县| 湘阴县| 郎溪县| 方城县| 綦江县| 兰州市| 上思县| 三明市| 安乡县| 闽清县| 渝北区| 罗源县| 浦县| 巴青县| 新安县| 东丽区| 东海县| 闸北区| 新巴尔虎右旗| 嘉义县| 芦山县| 多伦县| 荥经县| 辉南县| 莒南县| 河南省| 陇川县| 东宁县| 乌什县| 普定县| 嘉义县| 和静县| 阿克陶县| 桐城市| 新平| 榆树市|