제출 #857335

#제출 시각아이디문제언어결과실행 시간메모리
857335MarceantasyStone Arranging 2 (JOI23_ho_t1)C++17
35 / 100
27 ms2896 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array #define rep(i, n) for(int i = 0; i<(int)n; ++i) const int mxN = 2e5+5, MOD = 998244353; map<int, vector<int>> mp; void solve(){ int n; cin >> n; vector<int> ans(n); for(int i = 0; i<n; ++i){ int x; cin >> x; if(mp.count(x) && mp[x].size() >= 1){ int idx = i-1; while(idx > mp[x].back()){ mp[ans[idx]].pop_back(); ans[idx--] = x; } } mp[x].push_back(i); ans[i] = x; } cout << "\n"; rep(i, n){ cout << ans[i] << "\n"; } } int main(){ #ifdef _DEBUG // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...