제출 #897157

#제출 시각아이디문제언어결과실행 시간메모리
897157NonozeStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
300 ms6464 KiB
#include <iostream> #include <vector> #include <algorithm> 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; vector<int> apparition(n+1, -1); for (int i=1; i<n; i++) { if (temp[i].first!=temp[i-1].first) vv++; a[temp[i].second]=vv; apparition[vv]=temp[i].second; } 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; } int 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...