Submission #1256372

#TimeUsernameProblemLanguageResultExecution timeMemory
1256372tvgkStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
190 ms13340 KiB
#include<bits/stdc++.h> using namespace std; #define task "a" #define se second #define fi first #define ll long long #define ii pair<ll, ll> const long mxN = 2e5 + 7; int n, a[mxN]; map<int, int> cnt; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(task".INP", "r", stdin); //freopen(task".OUT", "w", stdout); cin >> n; stack<int> stk; for (int i = 1; i <= n; i++) { cin >> a[i]; cnt[a[i]]++; while (cnt[a[i]] > 1) { cnt[a[stk.top()]]--; stk.pop(); } stk.push(i); } for (int i = n; i >= 1; i--) { if (stk.size() && stk.top() == i) stk.pop(); else a[i] = a[i + 1]; } for (int i = 1; i <= n; i++) cout << a[i] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...