Submission #997286

#TimeUsernameProblemLanguageResultExecution timeMemory
997286faqinyeagerStone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
1 ms348 KiB
#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 - 1; 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; while(id < n){ int cur = a[id]; const vector<int>& positions = tmp[cur]; int start = G(positions, id), end = positions.back(); //cout << id << " ---> " << start << ' ' << end << '\n'; for(int i = start; i <= end; i++) cout << a[cur] << '\n'; id = end + 1; if(id > n) break; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...