#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 70001;
int N;
ll A[MN];
int pos[MN];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> N;
for (int i=0; i<N; ++i) {
cin >> A[i];
}
for (int i=N-1; i>0; --i) {
A[i] -= A[i-1];
}
list<int> order;
for (int i=0; i<N; ++i) {
ll cur = 1;
for (auto it=order.begin(); it!=order.end(); ++it) {
if (cur == A[i]) {
order.insert(it, i);
cur = -1;
break;
}
cur += A[*it];
}
if (cur == A[i]) {
order.push_back(i);
cur = -1;
}
assert(cur == -1);
//cerr << "order:";for (auto it=order.begin(); it!=order.end(); ++it) {cerr << ' ' << *it;} cerr << endl;
}
int idx = 0;
for (auto it=order.begin(); it!=order.end(); ++it) {
pos[*it] = ++idx;
}
for (int i=0; i<N; ++i) {
if (i) cout << ' ';
cout << pos[i];
}
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |