Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int N = 2e5 + 10, NN = 1e6;
const int mod = 7 + 1e9;
const ll oo = 1e9;
double eps = 1e-9;

void Ifyoufailtryagain(){
  int n, mx = 0, fr = 0;
  cin >> n;
  for(int i=0, t; i<n; ++i){
    cin >> t;
    if(t > mx){
      fr = 1;
      mx = t;
    }
    else
    if(t == mx)
      fr++;
  }
  while(fr--) 
    cout << mx << ' ';
  cout << '\n';
  return;
}

int main()
{
  ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
  int t = 1;
  cin >> t;
  while (t--)
    Ifyoufailtryagain();
}
Copy
To-do List fortyfive
GNU G++17
112 ms
824 KB
Accepted