Submission #897154

#TimeUsernameProblemLanguageResultExecution timeMemory
897154NonozeStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
277 ms6348 KiB
#include <bits/stdc++.h> using namespace std; int n, k, m; vector<int> a; void solve() { cin >> n; a.clear(); a.resize(n); vector<pair<int, int>> temp; for (int i=0; i<n; i++) { cin >> a[i]; temp.push_back({a[i], i}); } sort(temp.begin(), temp.end()); vector<int> ancien=a; a[temp[0].second]=0; int vv=0; for (int i=1; i<n; i++) { if (temp[i].first!=temp[i-1].first) vv++; a[temp[i].second]=vv; } vector<int> apparition(vv+1, -1); for (int i=0; i<n; i++) { apparition[a[i]]=i; } for (int i=0; i<n; i++) { int ct=ancien[i]; int temp=apparition[a[i]]; for (; i<temp; i++) { cout << ct << endl; } cout << ct << endl; } return; } signed main() { ios::sync_with_stdio(0); cin.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...