This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define ld long double
#define pb push_back
using namespace std;
using ll=long long;
const int MN = 2e5+5;
const int mod = 1e9+7;
const int inf = 1e18;
int n,a[MN];
map<int,int> cnt;
inline void solve() {
cin>>n;
for (int i=1; i<=n; i++) {
cin>>a[i];
cnt[a[i]]=i;
}
for (int i=1; i<=n; i++) {
if(cnt[a[i]]>i) {
for (int j=i; j<=cnt[a[i]]; j++) {
a[j]=a[i];
}
i=cnt[a[i]];
}
}
for (int i=1; i<=n; i++) {
cout<<a[i]<<"\n";
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t=1;
// cin>>t;
while(t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |