Submission #1106044

#TimeUsernameProblemLanguageResultExecution timeMemory
1106044LuvidiStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
225 ms28344 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define fs first #define sc second #define pb push_back void solve() { int n; cin>>n; vector<pii> v; map<int,vector<int>> idx; for(int i=0;i<n;i++){ int x; cin>>x; if(!idx[x].empty()){ int c=0; while(v.back().fs!=x){ c+=v.back().sc; idx[v.back().fs].pop_back(); v.pop_back(); } v.back().sc+=c+1; }else{ idx[x].pb(v.size()); v.pb({x,1}); } } for(auto[x,y]:v){ while(y--)cout<<x<<'\n'; } } int main() { #ifdef FPO freopen("in","r",stdin); freopen("out","w",stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...