Codeforces Round #703 (Div. 2)A. Shifting Stacks
作者:互联网
思路:
能满足条件的最低限度为{0,1,2,3,…,n}这种序列,因此我们只需要将给出的序列构造成这种序列就行。
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
ll a[110];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
ll sum = 0,ans = 0;
for(ll i = 0; i < n; i++)
{
scanf("%lld",&a[i]);
}
int flag = 0;
for(int i = 0; i < n; i++)
{
if(a[i] >= i)
{
a[i + 1] += a[i] - i;
}
else
{
printf("no\n");
flag = 1;
break;
}
}
if(flag == 1)
{
continue;
}
else
printf("yes\n");
}
return 0;
}
标签:int,ll,Codeforces,703,flag,Shifting,printf,序列,scanf 来源: https://blog.csdn.net/p15008340649/article/details/114155787