magic ranking time limit exceeded

help
c
c-plus-plus
easy
practice
runtime-error
sigsegv
time-limit

#1

I am having problems with magic ranking problem.

I am quite sure i am using the right approach and produce correct results in O(n^2) but I keep getting TLE .

would someone care to explain to me wat’s worng? thank you in advance .

here is my solution to the problem

and here is another solution with double array instead of vector and it gives me SIGSEGV .