Submission #955590

#TimeUsernameProblemLanguageResultExecution timeMemory
955590KakarotStone Arranging 2 (JOI23_ho_t1)C++98
100 / 100
228 ms29520 KiB
#include <bits/stdc++.h> #define int int64_t using namespace std; void setIO() { cin.tie(0)->sync_with_stdio(0); } void solve() { //cout << "zco"; int n; cin >> n; vector<int> stones(n); map<int, vector<int>> pos; for(int i = 0; i < n; i++) { cin >> stones[i]; pos[stones[i]].push_back(i); } // cout << pos[2].back() << '\n'; vector<int> ans(n); int idx = 0, i = 0; while(i < n && idx < n) { for(i = idx; i <= pos[stones[idx]].back(); i++) ans[i] = stones[idx]; idx = i; } for(auto &x : ans) cout << x << '\n'; } int32_t main() { setIO(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...