제출 #1205026

#제출 시각아이디문제언어결과실행 시간메모리
1205026namhhStone Arranging 2 (JOI23_ho_t1)C++20
0 / 100
0 ms400 KiB
#include<bits/stdc++.h> using namespace std; const int N = 2e5+1; int n,a[N],ans[N],pre[N]; unordered_map<int,int>mp; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = n; i >= 1; i--){ if(mp[a[i]] == 0) pre[i] = i; else pre[i] = mp[a[i]]; mp[a[i]] = i; } int x = 1; while(x <= n){ int cc = pre[x]; if(cc == x){ x = cc+1; continue; } for(int i = x; i <= cc; i++) ans[i] = a[x]; x = cc; } for(int i = 1; i <= n; i++) cout << ans[i] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...