Submission #357700

#TimeUsernameProblemLanguageResultExecution timeMemory
357700MlxaPermutation Recovery (info1cup17_permutation)C++14
25 / 100
1 ms620 KiB
#ifdef LC #include "pch.h" #else #include <bits/stdc++.h> #endif using namespace std; using ll = long long; #define int ll #define all(x) x.begin(), x.end() #define x first #define y second #define mp make_pair #define mt make_tuple const int N = 1e5; int n; int dp[N]; int a[N]; vector<int> pos; signed main() { #ifdef LC assert(freopen("input.txt", "r", stdin)); #endif ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) { cin >> dp[i]; } for (int i = n - 1; i >= 1; --i) { dp[i] -= dp[i - 1]; } for (int i = 0; i < n; ++i) { int ind = 0; int least = dp[i] - 1; while (ind < (int)pos.size() && least > 0) { least -= dp[pos[ind]]; ++ind; } // cout << i << " " << least << endl; assert(!least); pos.insert(pos.begin() + ind, i); } for (int i = 0; i < n; ++i) { a[pos[i]] = i + 1; } for (int i = 0; i < n; ++i) { cout << a[i] << " "; } cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...