This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;
int main(){
#if __has_include("LOCAL.hh")
#include "LOCAL.hh"
#endif
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
using namespace std::chrono;
cout << fixed << setprecision(9);
auto begin = steady_clock::now();
#else
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#endif
ll n;
cin>>n;
ll arr[n];
map<ll, ll> lastind;
for(int i=0; i<n; i++){
cin>>arr[i];
lastind[arr[i]] = i;
}
ll ans[n];
ll l = 0;
while(l<n){
ll temp = arr[l];
ll last = lastind[temp];
for(int i=l; i<=last; i++){
ans[i] = temp;
}
l = last+1;
}
for(int i=0; i<n; i++){
cout << ans[i] << endl;
}
#ifdef LOCAL
auto end = steady_clock::now();
cout << "\nTime : "
<< (ld)duration_cast<nanoseconds>
(end - begin).count()/1000000000
<< "s" << endl;
#endif
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |