Add a value to each of the array element between two given indices successively
Some general remarks:


System.out.println(queryLength);



The function should only return the result, but not print anything.


int a = 0 , b = 0 , k = 0;



The initial values are not used, and variables should be declared at the narrowest scope, in this case, inside the loop:

for(int i = 0 ; i &lt; queryLength ; i++ )
{
    int a = queries[i][0];
    int b = queries[i][1];
    int k = queries[i][2];
    // ...
}


Iterating over all queries can also be done with an “enhanced for loop”:

for (int[] query: queries)
{
    int a = query[0];
    int b = query[1];
    int k = query[2];
    // ...
}


Here


for(int j = (a-1) ; j &lt;= (b-1) ; j++)



the parentheses are not needed, and this


 p[j] = p[j] + k ;



can be shortened to 

p[j] += k ;


The initialization


// initialize p
for(int i = 0 ; i &lt; n ; i++)
{
    p[i] = 0 ;
}



is not needed because all elements are initialised to 0 by default.

It might be a matter of personal preference, but I would always put horizontal space around operators and keywords, e.g. in


if(p[i]&gt;max)



There are also some unneeded import statements, but those are given by the submission template.



But your real problem is that the algorithm is too slow. The inner loop runs up to \$ 10^{7} \$ times, for each of the up to \$ 2 \cdot 10^{5} \$ queries.

The main idea to improve the performance is to represent the data differently. Instead of storing and updating the array with the actual numbers, one can store and update an array which holds the differences between successive numbers.

Initially, all differences are zero.

Then for each query \$ (a, b, k) \$ you only have to update two entries in the differences array: One difference increases by \$ k\$, and one difference decreases by \$ k \$.

Finally you compute the actual numbers by accumulating the differences, and determine the maximum value. 

This should be much faster, because the inner loop has been eliminated.



Let's take the given example with \$n = 10\$ and the queries

a b k
1 5 3
4 8 7
6 9 1


Instead of maintaining an array of the \$ n \$ numbers


index:             1  2  3  4  5  6  7  8  9 10
initial array:    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
after (1, 5, 3):  [3, 3, 3, 3, 3, 0, 0, 0, 0, 0]
after (4, 8, 7):  [3, 3, 3,10,10, 7, 7, 7, 0, 0]
after (6, 9, 1):  [3, 3, 3,10,10, 8, 8, 8, 1, 0]


we maintain an array of \$ n+1 \$ differences, where each entry \$ d[i] \$  holds the difference \$a[i+1] - a[i] \$:


index:             0, 1  2  3  4  5  6  7  8  9 10
initial diffs:    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
after (1, 5, 3):  [3, 0, 0, 0, 0,-3, 0, 0, 0, 0, 0]
after (4, 8, 7):  [3, 0, 0, 7, 0,-3, 0, 0,-7, 0, 0]
after (6, 9, 1):  [3, 0, 0, 7, 0,-2, 0, 0,-7,-1, 0]
final array:         [3, 3, 3,10,10, 8, 8, 8, 1, 0]


Do you see that only two entries are updated for each query? Can you figure out the pattern? 

The final array is reconstructed by accumulating the final entries in the differences array.