Submission #963886

#TimeUsernameProblemLanguageResultExecution timeMemory
963886TranGiaHuy1508Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
148 ms15368 KiB
#include <bits/stdc++.h> using namespace std; void main_program(); signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); main_program(); } int n; map<int, int> mp; vector<int> v; stack<int> st; void main_program(){ cin >> n; v.resize(n); for (int i = 0; i < n; i++){ cin >> v[i]; if (mp[v[i]]){ while (!st.empty() && v[st.top()] != v[i]){ mp[v[st.top()]]--; st.pop(); } } mp[v[i]]++; st.push(i); } int crr = n; while (!st.empty()){ for (int i = st.top(); i < crr; i++){ v[i] = v[st.top()]; } crr = st.top(); st.pop(); } for (int i = 0; i < n; i++) cout << v[i] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...