Submission #1126513

#TimeUsernameProblemLanguageResultExecution timeMemory
1126513LucaIlieStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
234 ms12932 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5; int a[MAX_N + 1], frecv[MAX_N + 1]; unordered_map<int, int> pos; int main() { int n, m = 0; cin >> n; for ( int i = 1; i <= n; i++ ) { ++m; cin >> a[m]; frecv[m] = 1; if ( pos[a[m]] > 0 ) { int j = m - 1; frecv[j] += 1; while ( j > pos[a[m]] ) { pos[a[j]] = 0; frecv[pos[a[m]]] += frecv[j]; j--; } m = j; } else pos[a[m]] = m; } for ( int i = 1; i <= m; i++ ) { for ( int j = 0; j < frecv[i]; j++ ) cout << a[i] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...