Submission #1322973

#TimeUsernameProblemLanguageResultExecution timeMemory
1322973cubedStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
158 ms16456 KiB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define f first
// #define s second
#define pb(x) push_back(x)
#define int long long


/*
ORDERED SET PDBS

#include <bits/extc++.h>
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
*/

const int MOD = 1e9+7;
const int inf = 1e9;
const int INF = 1e18+20;
const int LOG = 25;

void solve() {
    int n;
    cin>>n;

    vector<int> a(n);
    map<int, int> last;

    for (int i=0; i<n; i++) {
        cin>>a[i];
        last[a[i]]= i;
    }

    for (int i=0; i<n; i++) {
        int e = last[a[i]];
        
        for (int j=i; j<=e; j++) {
            a[j]=a[i];
        }

        i=e;
    }

    for (auto i:a) cout<<i<<endl;


}

bool multi=false;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t=1;
    if (multi) cin>>t;
 
    while (t--) solve();
 
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...