fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <map>
  5. using namespace std;
  6.  
  7. int main(){
  8. int t;
  9. cin >> t;
  10. while(t--){
  11. map<int, int> m;
  12. int n;
  13. cin >> n;
  14. for(int i = 0; i < n; i++){
  15. int a;
  16. cin >> a;
  17. m[a]++;
  18. cout << (--m.end())->first << " ";
  19. }
  20. cout << endl;
  21. }
  22. }
  23.  
Success #stdin #stdout 0.01s 5284KB
stdin
4
2
1 2
4
1 1 1 2
8
4 5 5 5 1 1 2 1
10
1 1 2 2 1 1 3 3 1 1
stdout
1 2 
1 1 1 2 
4 5 5 5 5 5 5 5 
1 1 2 2 2 2 3 3 3 3