I am new to algorithms so sorry to ask simple question
I am working on a problem which is about array of integers, my solution is right but not good enough, because I have time exceeded exception on codeforces. I think solution where solution's time < O(n^2) would be right.
My solution:
int n;
cin >> n;
int currentScore = n;
int credits[n];
int grades[n];
for (int i = 0; i < n; i++) {
cin >> credits[i];
for (int j = 0; j < i; j++) {
if (credits[i] <= credits[j]) {
currentScore--;
}
}
grades[i] = currentScore;
currentScore = n;
}
for (int i = 0; i < n; i++) {
cout << grades[i] << endl;
}
return 0;
