제출 #944500

#제출 시각아이디문제언어결과실행 시간메모리
944500vladiliusStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
147 ms14600 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n; cin>>n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++){
        cin>>a[i];
    }
    map<int, int> mp;
    for (int i = n; i > 0; i--){
        if (mp.find(a[i]) != mp.end()){
            continue;
        }
        mp[a[i]] = i;
    }
    int i = 1;
    while (i <= n){
        int x = a[i], t = mp[x];
        while (i <= t){
            a[i++] = x;
        }
    }
    for (int i = 1; i <= n; i++){
        cout<<a[i]<<"\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...