# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997296 | faqinyeager | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 0 ms | 348 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>
#define ff first
#define ss second
using namespace std;
using ll = long long;
int n;
vector<int> a;
int G(const vector<int>& b, ll x){
int l = 0, r = b.size() - 1;
while(r - l > 1){
int mid = (l + r) / 2;
if(a[mid] >= x) r = mid;
else l = mid;
}
return b[l];
}
int main(){
cin >> n;
a.resize(n);
map<int, vector<int>> tmp;
for(int i = 0; i < n; i++) cin >> a[i], tmp[a[i]].push_back(i);
int id = 0, pr = 0;
while(id < n){
int cur = a[id];
const vector<int>& positions = tmp[cur];
int start = G(positions, id), end = positions.back();
//cout << cur << ' ' << id << " ---> " << start << ' ' << end << '\n';
for(int i = start; i <= end; i++) cout << cur<< '\n';
id = end + 1;
if(id > n) break;
}
}
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... |