Pagini recente » Cod sursa (job #2224519) | Cod sursa (job #493674) | Cod sursa (job #1639198) | Cod sursa (job #1145178) | Cod sursa (job #3152289)
//#include <iostream>
//#include <string.h>
//#include <random>
//#include <fstream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <time.h>
//#include <iomanip>
//#include <algorithm>
//#include <math.h>
//#include <cmath>
//#include <vector>
//#include <stack>
//#include <queue>
//#include <array>
//#include <bitset>
//#include <map>
//#include <set>
//#include <unordered_map>
//#include <unordered_set>
//#include <complex>
//#include <valarray>
//#include <memory>
//#include <cassert>
//#include <chrono>
//#include <type_traits>
//#include <stdexcept>
//#include <string_view>
//#include <regex>
//using namespace std;
////#include <ext/pb_ds/assoc_container.hpp>
////#include <ext/pb_ds/tree_policy.hpp>
////using namespace __gnu_pbds;
////template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//typedef pair<int, int> pii;
//typedef pair<int, string> pis;
//typedef pair<pis, string> piss;
//typedef pair<int, short> pish;
//typedef pair<string, string> pss;
//typedef pair<int, char> pic;
//typedef pair<pii, int> piii;
//typedef pair<double, double> pdd;
//typedef pair<double, int> pdi;
//typedef pair<float, float> pff;
//typedef long long ll;
//typedef long double ld;
//typedef unsigned long long ull;
//typedef unsigned int uint;
//typedef unsigned short ushort;
//typedef pair<uint, uint> puint;
//typedef pair<ll, ll> pll;
//typedef pair<pll, ll> plll;
//typedef pair<pll, ld> plld;
//typedef pair<ld, int> pldi;
//typedef pair<int, ll> pil;
//typedef pair<ll, int> pli;
//typedef pair<ull, ull> pull;
//typedef pair<ld, ld> pld;
//typedef complex<double> cd;
////#define max(n, m) ((n>m)?n:m)
////#define min(n, m) ((n<m)?n:m)
//#define f first
//#define s second
//#define input() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
////#define eps 1e-8
////#define eps2 1e-15
//#define leni(x) sizeof(x)/sizeof(int)
//#define v(i,j,k) for(i=j;i<k;i++)
////#define cin fin
////#define cout fout
////#define fin cin
////#define fout cout
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <fstream>
#include <math.h>
#include <stdio.h>
using namespace std;
/*
._________.
|_________|
---------------
|_____• U •_____|
-------------------
|___________________|
*/
ifstream fin("schi.in");
ofstream fout("schi.out");
void readInt(int &number)
{
char c;
fin.get(c);
for (; (c > 47 && c < 58); fin.get(c))
number = number*10 + c-48;
}
int n, nums[30010], ans[30010], bit[30010];
int main()
{
readInt(n);
for(int i = 0; i < n; i ++)
readInt(nums[i]);
int lg = log2(n-1), idx, cur, llg;
for(int i = 1; i <= n; i ++)
bit[i] = (i) & (-i);
for(int i = n-1; i >= 0; i --)
{
idx = cur = 0;
for(int j = lg; j >= 0; j--)
{
llg = (1<<j);
if(idx+llg < n && cur + bit[idx+llg] < nums[i])
{
idx += llg;
cur += bit[idx];
}
}
ans[idx] = i+1;
idx ++;
while(idx < n)
{
bit[idx] --;
idx += idx & (-idx);
}
}
string ansS = "";
ansS.reserve(n*6);
for(int i = 0; i < n; i ++)
{
ansS.append(to_string(ans[i]));
ansS.append("\n");
}
fout << ansS;
}
/*
7 1 1
- 1 2
8 1 1
6 1 4
- 1 1
- 1 2
5 1 1
- 1 8
*/