Source Code
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
 
void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    vector<ll> cs(n + 1);
    for (int i = 1; i <=    n; i++) {
        cs[i] = cs[i - 1] + v[i - 1];
    }

    int st = 0;
    for (int i = 0; i < n; i++) {
        double avg = double(cs[n] - cs[st]) / (n - st);
        while (v[st] < avg) {
            st++;
            if (st == n) goto print;
        }
    }

print:
    if (st == n) cout << -1 << '\n';
    else {
        while (st < n)
        {
            cout << v[st++] << ' ';
        }
        cout << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Copy
To-do List OsamaX01
GNU G++17
139 ms
6.2 MB
Wrong Answer