Submission #897141

#TimeUsernameProblemLanguageResultExecution timeMemory
897141belgianbotStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
136 ms6748 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...