Untitled
unknown
plain_text
a month ago
911 B
0
Indexable
Never
#include <bits/stdc++.h> #define endl '\n' #define maxn 105 #define TASK bai1 #define For(i,a,b) for ( int i = a; i <= b; i++ ) #define MOD 100000000000007 using namespace std; int a[maxn],n,j,b[maxn],d = 0,c[maxn]; void inp() { cin >> n; For(i,1,n) { cin >> a[i]; a[i] += 1; } } void solve() { int i = n; j = n; while(i > 0) { if (b[j] == 0) { d++; if (d == a[i]) { c[i] = j; b[j] = 1; i--; d = 0; } } j--; if (j == 0) j = n; } For(i,1,n) cout << c[i] << " "; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen("bai1.inp","r")){ freopen("bai1.inp","r",stdin); } inp(); solve(); return 0; }
Leave a Comment