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;
vector <int> ans;
vector<int> t;
struct stone{
int a, index;
bool operator< (const stone &b) const{
return (a < b.a || (a == b.a && index < b.index));
}
bool operator> (const stone &b) const{
return (a > b.a || (a == b.a && index >= b.index));
}
};
int main() {
int N; cin >> N;
t.resize(N);
vector <stone> sorted(N);
for (int i(0); i < N; i++) {
cin >> t[i];
sorted[i] = {t[i], i};
}
sort(sorted.begin(), sorted.end());
for (int i(0); i < N; i++) {
stone b = {t[i], N};
int a = sorted[distance(sorted.begin(), upper_bound(sorted.begin(), sorted.end(), b)) - 1].index;
for (; i <= a; i++) cout << t[a] << '\n';
i--;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |