Submission #752872

#TimeUsernameProblemLanguageResultExecution timeMemory
752872WarinchaiStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
292 ms15316 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; map<int,int>mp; stack<pair<int,int> >st; for(int i=0;i<n;i++){ int a; cin>>a; if(mp[a]==0){ st.push({a,1}); mp[a]++; }else{ int sz=1; while(st.top().first!=a){ sz+=st.top().second; mp[st.top().first]-=st.top().second; st.pop(); } sz+=st.top().second; mp[a]-=st.top().second; st.pop(); st.push({a,sz}); mp[a]+=sz; } } stack<pair<int,int> >st2; while(!st.empty()){ st2.push(st.top()); st.pop(); } while(!st2.empty()){ int a=st2.top().first; int j=st2.top().second; for(int i=0;i<j;i++){ cout<<a<<"\n"; } st2.pop(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...