Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long

void FastCode (){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main() {

    FastCode();

    int tt;
    cin >> tt;
    while(tt--){
       int size;
       cin >> size;
       ll arr[size];
       for (int i = 0 ; i < size ; i++){
           cin >> arr[i];
       }
       //sort(arr,arr+size);
       int max  = 0;
       //bool flag = 0;
       int i  ;
       for (i = 0  ; i < size ; i++){
           
               if (max < arr[i])
                   max = arr[i];
              //flag = 1;
           }for(int i = 0 ; i < size ; i++)
               if (arr[i] == max){
               		cout<<max << " ";
			   }
			   cout << endl;
           }
           
       }
//       if (flag)
//           cout << max << endl;
    
Copy
To-do List YoussefAbdelhakem
GNU G++17
41 ms
2.2 MB
Accepted