# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924046 | Sunbae | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 95 ms | 16836 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int A[N], m;
vector<int>C, V[N];
int pos(int x){return lower_bound(C.begin(), C.end(), x) - C.begin();}
signed main(){
int n; scanf("%d", &n);
for(int i = 0; i<n; ++i) scanf("%d", A+i), C.push_back(A[i]);
sort(C.begin(), C.end());
C.resize(unique(C.begin(), C.end()) - C.begin()); m = C.size();
for(int i = 0; i<n; ++i) A[i] = pos(A[i]);
for(int i = 0; i<n; ++i) V[A[i]].push_back(i);
for(int l = 0, r = -1; l<n && r<n; ){
l = r + 1;
r = V[A[l]].back();
for(int j = l; j<=r; ++j) printf("%d\n", C[A[l]]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |