Submission #798795

#TimeUsernameProblemLanguageResultExecution timeMemory
798795vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
60 / 100
2133 ms1009344 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 10; int n; int a[N]; vector<int> st[N]; map<int, int> mp, key; void compose() { for(int i = 0; i < n; i++) mp[a[i]] = 1; int k = 0; for(auto &c : mp) { c.second = k++; key[c.second] = c.first; } for(int i = 0; i < n; i++) a[i] = mp[a[i]]; } int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin >> n; for(int i = 0; i < n; i++) cin >> a[i]; compose(); for(int i = 0; i < n; i++) { if(st[a[i]].empty()) st[a[i]].push_back(i); else { int lst = st[a[i]].back(); for(int j = i - 1; j > lst; j--) st[a[j]].pop_back(); while(lst < i) { a[++lst] = a[i]; st[a[lst]].push_back(lst); } } } for(int i = 0; i < n; i++) cout << key[a[i]] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...