Submission #1101054

#TimeUsernameProblemLanguageResultExecution timeMemory
1101054Kirill22Permutation Recovery (info1cup17_permutation)C++17
25 / 100
1 ms508 KiB
#include "bits/stdc++.h" using namespace std; void solve() { int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i; i--) { a[i] -= a[i - 1]; } vector<int> ord = {0}; for (int i = 1; i < n; i++) { long long tmp = 1; for (int j = 0; j <= (int) ord.size(); j++) { if (j) { tmp += a[ord[j - 1]]; } if (tmp == a[i]) { ord.insert(ord.begin() + j, i); break; } } } vector<int> ans(n); for (int i = 0; i < n; i++) { ans[ord[i]] = i; } for (int i = 0; i < n; i++) { cout << ans[i] + 1 << " "; } cout << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t--) { solve(); } }
#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...