Submission #1188167

#TimeUsernameProblemLanguageResultExecution timeMemory
1188167mehdibaStone Arranging 2 (JOI23_ho_t1)C++20
25 / 100
2094 ms1096 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) sizeof(a) / sizeof(a[0])
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++){
		int tt;
		// find the latest occurence of a[i]
		for(int j = n - 1; j >= 0; j--) if(a[j] == a[i]){
			tt = j;
			break;
		}
		for(int j = i + 1; j < tt; j++) a[j] = a[i];
	}
	for(int x : a) cout << x << '\n';
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...