AlarmOA #1
Arrange Coins
Estimated EasyJudge-ready
Topics (AI-labelled)Bits & MathBinary Search
Given several non-negative integers coins. For each n, place coins row by row starting from the first row: row 1 needs 1 coin, row 2 needs 2 coins, and so on. Only completely filled rows count; find the maximum number of rows each n can fill.
Input
The first line is the array length N, and the second line contains N integers. Site constraints: 1≤N≤100000, 0≤coins[i]≤10^9.
Output
Output N integers, the number of rows each coins[i] can fill, in order.
Example 1
Input:
3
3 4 6
Output:
2 2 3
Example 2
Input:
7
0 1 2 3 5 8 10
Output:
0 1 1 2 2 3 4
Example 3
Input:
2
999999999 1000000000
Output:
44720 44720
Editorial
Loading solution…