-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
35 lines (35 loc) · 765 Bytes
/
A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
scanf("%d", &n);
map <int, vector <int>> cont;
for(int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
cont[x].push_back(i);
}
vector <int> can (n + 1, INT_MAX);
for(auto i : cont) {
vector <int> v = i.second;
v.insert(v.begin(), -1);
v.insert(v.end(), n);
int opt = 0;
for(int j = 1; j < v.size(); j++) {
int free = v[j] - v[j - 1] - 1;
opt = max(opt, free + 1);
}
can[opt] = min(can[opt], i.first);
}
for(int i = 1; i <= n; i++) {
can[i] = min(can[i - 1], can[i]);
if(can[i] < INT_MAX) printf("%d ", can[i]);
else printf("-1 ");
}
printf("\n");
}
int main() {
int t;
scanf("%d", &t);
while(t--) solve();
}