1810A - Beautiful Sequence - CodeForces Solution


brute force

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;


/* -------------PBD------------*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
//if less_equal than multiset behaviour ,if greater than descending order arrange


typedef             long double ld;
typedef             long long ll;
typedef             unsigned long long ull;
#define in(x)       ll x;cin>>x
#define in2(x,y)    ll x,y;cin>>x>>y
#define pb          push_back
#define pll         pair<ll,ll>
#define vi          vector<int>
#define mi          map<int,int>
#define mll          map<ll,ll>
#define umi         unordered_map<ll,ll>
#define vll         vector<long long>
#define pii         pair<int,int>
#define pi          3.14159265358979323846
#define test()         ll t; cin >> t; while(t--)
#define loop(i,j,n)    for(ll i=j;i<n;i++)
#define loopr(i, n)    for (int i = n-1; i >= 0; i--)
#define print(x)       cout<<x<<endl;
//#define sort(v)        sort(v.begin(),v.end(),compare);
#define FASTIO         ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 1e9 + 7;
//for giving number to array
 //memset(dp, -1, sizeof(dp));


bool compare(int a,int b){
return a>b;
}
// Operator overloads
// cout << vector<T>
template<typename T> ostream& operator<<(ostream &ostream, const vector<T> &c) {for (auto &it : c) cout << it << " "; return ostream;}
// cin >> vector<T>
template<typename T> istream& operator>>(istream &istream, vector<T> &v) {for (auto &it : v) cin >> it; return istream;}
// descend st
auto cmp = [](int a, int b) { 
return  a>b ;
};
set<int,decltype(cmp)> s1(cmp);
set<ll>::iterator itr;
//bitset<32> bs(5)


/*----------------func-------------*/


template<typename T>
void display(vector<T> v ){
for(auto x : v){
cout<<x<<' ';
}
cout<<endl;
}
/*----------------------Code--------------------------*/


int main() {


#ifndef ONLINE_JUDGE
freopen("Error.txt", "w", stderr);
#endif
FASTIO;


      test(){


            int n;
            cin>>n;

            int arr[n];

            loop(i,0,n){

                  cin>>arr[i];
            }

            bool ok=false;
            int cnt=0;

            for(int i=0;i<n;i++){


                  cnt+=1;

                  if(arr[i]<=cnt){

                        ok=true;
                        break;
                  }

            }

            if(ok){

                  print("YES")
            }
            else{
                  print("NO")
            }




      }



      return 0;


}


Comments

Submit
0 Comments
More Questions

810B - Summer sell-off
84A - Toy Army
185A - Plant
1749A - Cowardly Rooks
1749C - Number Game
1749B - Death's Blessing
1749D - Counting Arrays
1447B - Numbers Box
1594D - The Number of Imposters
984B - Minesweeper
837A - Text Volume
1566C - MAX-MEX Cut
1546A - AquaMoon and Two Arrays
897B - Chtholly's request
1363B - Subsequence Hate
437B - The Child and Set
1256B - Minimize the Permutation
733B - Parade
172A - Phone Code
148D - Bag of mice
421A - Pasha and Hamsters
1393A - Rainbow Dash Fluttershy and Chess Coloring
980E - The Number Games
219B - Special Offer Super Price 999 Bourles
560B - Gerald is into Art
322B - Ciel and Flowers
801B - Valued Keys
975C - Valhalla Siege
518B - Tanya and Postcard
514B - Han Solo and Lazer Gun