Submission #919623

#TimeUsernameProblemLanguageResultExecution timeMemory
919623andrei_iorgulescuStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
143 ms14156 KiB
#include <bits/stdc++.h> using namespace std; int n,a[200005]; map<int,bool>am; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; vector<pair<int,int>>v; for (int i = 1; i <= n; i++) { if (!am[a[i]]) { am[a[i]] = true; v.push_back({a[i],1}); } else { int cate = 1; while (v.back().first != a[i]) { cate += v.back().second; am[v.back().first] = false; v.pop_back(); } v[v.size() - 1].second += cate; } } for (auto it : v) for (int i = 1; i <= it.second; i++) cout << it.first << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...