Help me in solving KO_MON problem

My issue

include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin >> t;
while (t–) {
int n, x;
cin >> n >> x;
vector a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());

    int ans = 0, hp;

    for (int i = 0; i < n; i++) {
        hp = a[i] + i * x;
        ans = max(ans, hp);
    }
    cout << ans << endl;
}

return 0;

}
I feel llike this is correct, no?

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, x;
        cin >> n >> x;
        vector<long long> a(n);

        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.rbegin(), a.rend());

        int ans = 0, hp;

        for (int i = 0; i < n; i++) {
            hp = a[i] + i * x;
            ans = max(ans, hp);
        }
        cout << ans << endl;
    }

    return 0;
}

Problem Link: Monster Monster Practice Coding Problem