Submission #875590

#TimeUsernameProblemLanguageResultExecution timeMemory
875590hmm789Stone Arranging 2 (JOI23_ho_t1)C++14
60 / 100
2044 ms11980 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000000
#define MOD 998244353
 
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    map<int, int> m;
    for(int i = 0; i < n; i++) {
        if(m.find(a[i]) != m.end()) {
            for(int j = m[a[i]]+1; j < i; j++) {
                m.erase(a[j]);
                a[j] = a[i];
            }
        }
        m[a[i]] = i;
    }
    for(int i = 0; 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...