Submission #736213

#TimeUsernameProblemLanguageResultExecution timeMemory
736213CookieStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
217 ms14204 KiB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("WINTER.inp");
ofstream fout("WINTER.out");

#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;

const ll mod = 1e9 + 7;
const int mxn = 2e5, mxm = 1e5, sq = 400;
const int base = (1 << 18);
const ll inf = 1e9;
const ld pre = 1e-6;
map<int, int>mp;
int n;
int a[mxn + 2], ans[mxn + 1];
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    forr(i, 0, n){
        cin >> a[i]; mp[a[i]] = i;
    }
    int id = 0;
    while(id < n){
        for(int i = id; i <= mp[a[id]]; i++)ans[i] = a[id];
        id = mp[a[id]] + 1;
    }
    forr(i, 0, n){
        cout << ans[i] << "\n";
    }
    return(0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...