#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
vector<ll> g[409];
ll a[409];
ll n;
ll beg = 0;
ll fr[409];
ll ans[409];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n;
for(ll i = 1; i <= n; ++i)
cin >> a[i];
for(ll i = n; i >= 1; --i)
a[i] -= a[i-1];
for(ll i = 1; i <= n; ++i){
if(a[i] == 1){
fr[i] = beg;
beg = i;
continue;
}
ll cur = 0;
ll idx = beg;
while(1){
cur += a[fr[idx]];
if(fr[idx] == 0 || cur == a[i]-1){
fr[i] = fr[idx];
fr[idx] = i;
break;
}
idx = fr[idx];
}
}
ll idx = beg;
ll cnt = 1;
while(idx){
ans[idx] = cnt++;
idx = fr[idx];
}
for(ll i = 1; i <= n; ++i)
cout << ans[i] << ' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |