#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a)
cin >> i;
vector<int> p(n);
iota(all(p), 1);
do {
bool tr = true;
vector<int> v(n, 1);
for (int i = 0; i < n && tr; i++) {
for (int j = 0; j < i; j++)
if (p[j] < p[i]) v[i] += v[j];
tr = (a[i] - (i ? a[i - 1] : 0) == v[i]);
}
if (tr) {
for (auto i : p)
cout << i << ' ';
return 0;
}
} while (next_permutation(all(p)));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |