Maximum Sum of Array

0

0 votes
Problem

You are given an integer N size of the array and an empty array means initially all the elements of the array is zero.
You have to fill the array using the function given below:-
for(int i = 0; i < N; i++)
{
       for( int j = i; j < N; j++ )
       {
            arr[j] += 1;
        }
}
Print the maximum sum of the array.


Input Format:
First line contains an integer T number of testcases.
Second line of each test case contains only an integer N size of the array.


Output Format:
For each test case print maximum sum of the array.


Constraint :
1<=T<=2001<=N<=1012

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

for test case 1: N == 1 so array will have only 1 element that is 1 so sum is 1
for test case 2: N == 2 so size of the array is 2 . so the array would be 1 1 in first
iteration and then 1 2 in 2nd iteration.
So sum would be max in 2nd iteration that is 3.

Editor Image

?