제출 #1333240

#제출 시각아이디문제언어결과실행 시간메모리
1333240mtilordStone Arranging 2 (JOI23_ho_t1)C++20
35 / 100
15 ms832 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
using namespace std;

int mas[200001];
bool test[200001];
int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, s, b;
    cin >> n;
    vector<pii> mas;
    for(int i=1; i<=n; i++)
    {
        int a;
        cin >> a;
        if(test[a]==0)
        {
            test[a]=1;
            mas.pb({a, i});
        }
        else
        {
            while(mas.back().fi!=a)
            {
                test[mas.back().fi]=0;
                mas.pop_back();
            }
        }
    }
    int x, y=0;
    for(int i=0; i<n; i++)
    {
        if(y+1<mas.size() && i+1==mas[y+1].se)
            y++;
        x=mas[y].fi;
        cout << x << endl;
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...