Source Code
#include <fstream>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <set>
using namespace std;

int main()
{
    int _;
    cin>>_;
    while (_--)
    {
        long long n,ans=0;
        cin>>n;
        vector<long long>ary;
        for(int i=0; i<n; i++)
        {
            int x;
            cin>>x;
            ary.push_back(x);
        }
        sort(ary.begin(), ary.end());
        long long x=ary[n-1];
        while (x==ary[n-1])
        {
            cout<<ary[n-1]<<" ";
            n--;
        }
        cout<<endl;
    }
}
Copy
To-do List Abbro
GNU G++17
236 ms
2.5 MB
Accepted