You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
using namespace std;
|
|
|
|
|
// 通过了 7/10个数据
|
|
|
|
|
|
|
|
|
|
const int N = 1e5 + 10;
|
|
|
|
|
int h[N];
|
|
|
|
|
int st[N];
|
|
|
|
|
int ans[N];
|
|
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
scanf("%d", &n);
|
|
|
|
|
|
|
|
|
|
for (int i = 2; i <= n; i++) scanf("%d", &h[i]);
|
|
|
|
|
// 第一个放过,不讨论,输进来也是0,不输也是0
|
|
|
|
|
|
|
|
|
|
for (int i = n; i; i--) { // 从后向前枚举每头牛
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
for (int j = 1; j <= n; j++) {
|
|
|
|
|
if (!st[j]) cnt++; // 如果此位置没有被占用,是可以用的
|
|
|
|
|
if (cnt == h[i] + 1) { // 寻找第h[i]+1个未被占据的位置
|
|
|
|
|
st[j] = 1; // 标识此位置被某个奶牛占据过了
|
|
|
|
|
ans[i] = j; // 记录i号奶牛占据的是j号位置
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|