要求加上x之后严格大于右边的数。
要注意的是严格大于右边的数。
#include
#include
#include
#include
using namespace std;
const int N = 100001;
int a[N];
int b[N];
int main(void)
{
int n;
while(~scanf("%d", &n))
{
int i, j;
for(i = 1; i <= n; i++)
scanf("%d",&a[i]);
b[n] = 0;
int MAX = a[n];
for(i = n-1; i >= 1; i--)
{
if(a[i] <= MAX)
b[i] = MAX+1-a[i];
else
b[i] = 0;
if(MAX < a[i]) MAX = a[i];
}
for(i = 1; i < n; i++)
printf("%d ", b[i]);
printf("%d\n", b[n]);
}
return 0;
}