# Codeforces Round #616 (Div. 2) B. Array Sharpening

（1）0,1,2,3,4........n-3,n-2,n-1

（2）n-1,n-2,n-3.....3,2,1,0

（3）0,1,2,3,4,.....n.......4,3,2,1,0

 1 #include <iostream>
2 using namespace std;
3
4 const int N = (int)3e5+100;
5 int a[N];
6
7 int main(){
8
9     int T,n;
10     while(cin >> T){
11         while(T--){
12             cin >> n;
13             for(int i = 1; i <= n; ++i) cin >> a[i];
14             int i;
15             bool ok = 1;
16             //递增区间判断
17             for(i = 1; i <= n; ++i){
18                 if(a[i] >= i-1) continue;
19                 break;
20             }
21             // 0 1 1 0 这种情况判定
22             if(i <= n){
23                 if(a[i] == a[i-1] && !(a[i] >= n-i+1)) ok = 0;
24             }
25             //递减区间判定
26             for(; i <= n; ++i){
27                 if(a[i] >= n-i) continue;
28                 ok = 0; break;
29             }
30             //if(ok) cout << "----------Yes" << endl;
31             //else cout << "----------No" << endl;
32             if(ok) cout << "----------Yes" << endl;
33             else cout << "----------No" << endl;
34         }
35     }
36
37 }

posted @ 2020-02-04 15:53  SummerMingQAQ  阅读(...)  评论(...编辑  收藏