Source Code
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
const int mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int arr[n];
        for(int i = 0; i < n; i++) cin >> arr[i];
        int mx = *max_element(arr, arr + n);
        for(int i = 0; i < n; i++){
            if(arr[i] == mx) cout << mx << " ";
        }
        cout << "\n";
    }
    return 0;
}  
Copy
To-do List AbduSaber
GNU G++17
81 ms
1.2 MB
Accepted