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>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N; cin >> N;
vector<int> arr(N);
for(int i = 0;i<N;++i) cin >> arr[i];
vector<array<int,3>> vec;
multiset<int> alive;
for(int i = 0;i<N;++i){
if(alive.find(arr[i]) == alive.end()){
//cout << i << "\n";
alive.insert(arr[i]);
vec.push_back({i,i,arr[i]});
}
else{
while(vec.back()[2] != arr[i] && !vec.empty()){
alive.erase(alive.find(vec.back()[2]));
vec.pop_back();
}
array<int,3> a = {0,i,arr[i]};
if(vec.size()){
a[0] = vec.back()[1]+1;
}
vec.push_back(a); alive.insert(arr[i]);
}
}
for(auto x : vec){
//cout << x[0] << " " << x[1] << "\n";
for(int i = 0;i<=x[1]-x[0];++i){
cout << x[2] << "\n";
}
}
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... |