Submission #763837

#TimeUsernameProblemLanguageResultExecution timeMemory
763837NK_Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
195 ms15176 KiB
#include <bits/stdc++.h> using namespace std; #define nl '\n' int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; vector<int> A(N); for(auto& x : A) cin >> x; map<int, int> mx; for(int i = 0; i < N; i++) mx[A[i]] = max(mx[A[i]], i); vector<int> ans(N); for(int i = 0; i < N; i++) { int nxt = mx[A[i]]; for(int j = i; j <= nxt; j++) ans[j] = A[i]; i = nxt; } for(auto x : ans) cout << x << nl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...