이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define int long long
multiset<pair<int, int>> ms;
void solve(){
int n;
cin >> n;
int a[n];
for(int i=0; i< n; i++){
cin >> a[i];
ms.insert({a[i], i});
}
int ans[n];
for(int i=0; i< n; i++){
auto ptr = ms.lower_bound({a[i], i+1});
if(ptr!=ms.end() && (*ptr).F==a[i]){
int ind=(*ptr).S;
for(int j=i; j<=ind; j++){
ans[j]=a[i];
ms.erase({a[j], j});
}
i=ind-1;
}
else{
ans[i]=a[i];
}
}
for(int e : ans)cout << e << '\n';
cout << '\n';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
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... |