P11157 【MX-X6-T3】さよならワンダーランド - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
想复杂了,把需要的东西整理整理,就全出来了,列出适合的不等式后,可能就是个橙色。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 300010, M = ceil(log(N));
int n, m;
int g[N], a[N];
int w[N];
PII sum[N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++ )
scanf("%d", &a[i]), w[i] = i - a[i];
sum[n + 1] = {0x3f3f3f3f, n + 1};
for (int i = n; i; i -- )
{
if (sum[i + 1].x > w[i]) sum[i] = {w[i], i};
else sum[i] = sum[i + 1];
}
for (int i = 1; i <= n; i ++ )
{
auto x = sum[max(1, min(a[i] + i, n + 1))];
if (x.x <= i && x.y != n + 1) cout << 1 << ' ' << x.y - i;
else cout << 0;
puts("");
// cout << x.x << ' ' << x.y << endl;
}
return 0;
}
送一组hack
20
-2 3 -2 -10 3 8 -1 5 4 9 -4 1 0 3 -7 5 3 0 -2 -5
1 5
1 4
1 3
1 2
1 5
0
1 -1
0
0
0
1 -1
1 4
1 3
1 3
1 -5
0
0
1 0
1 -2
1 -4
标签:int,sum,T3,P11157,include,X6,MX
From: https://www.cnblogs.com/blind5883/p/18462259