제출 #774651

#제출 시각아이디문제언어결과실행 시간메모리
774651vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define st first #define nd second signed main(){ cin.tie(0)->sync_with_stdio(0); int n; cin >> n; int a[n + 1]; for(int i = 1; i <= n ; i++) cin >> a[i]; int ans[n + 1]; int ptr = n, tmp = n - 1; ans[n] = a[n]; while(ptr >= 1){ while(a[tmp] != a[ptr] && tmp >= 1){ ans[tmp] = ans[ptr]; tmp--; } ans[tmp] = ans[ptr]; ptr = tmp - 1; ans[ptr] = a[ptr]; tmp = ptr - 1; } for(int i = 1 ; i <= n ; i++) cout << ans[i] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...