Source Code
#include<bits/stdc++.h>
#include<cstdlib>
#define ll long long
#define ln length()
#define sz size()
#define ff first
#define ss second
#define pq priority_queue<ll,vector<ll>,greater<ll>>
#define all(v) v.begin(),v.end()
#define FS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ul unsigned long long
#define tc ll tt; cin>>tt; while(tt--)
#define ld long double
#define ln length()
#define el "\n"
#define ts(c) to_string(c)

using namespace std;

int main()
{
    FS
    tc {
        ll n,mx=0;
        cin>>n;
        map<ll,ll>mp;
        for (int i=0;i<n;i++){
            ll x;cin>>x;
            mp[x]++;
            mx = max(mx,x);
        }
        for (int i=0;i<mp[mx];i++) cout<<mx<<' ';
        cout<<el;
    }
}
Copy
To-do List heba.daraghmeh
GNU G++17
387 ms
7.3 MB
Accepted