Codeforces Round 856 Div 2 | Problem C : Scoring Subsequences Solution | Explanation + Code | Hindi

Поделиться
HTML-код
  • Опубликовано: 9 ноя 2024

Комментарии • 17

  • @KaranMashru
    @KaranMashru Год назад +1

    Code :
    #include
    using namespace std;
    #define ll long long
    ll bs(ll l, ll h, ll a[], ll i)
    {
    if(l=(i-m+1)){
    if(m==l){
    return m;
    }else{
    if(a[m-1]>=(i-(m-1)+1)){
    return bs(l, m-1, a, i);
    }else{
    return m;
    }
    }
    }else{
    bs(m+1, h, a, i);
    }
    }else{
    return -1;
    }
    }
    int main()
    {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t, n, i, j;

    cin>>t;

    for(;t--;)
    {
    cin>>n;

    ll a[n], ans[n];

    for(i=0; i>a[i];
    }

    ans[0]=1;

    for(i=1; i

  • @Mihir_kathpal
    @Mihir_kathpal 2 месяца назад +1

    very good explainations , Thanks buddy

  • @eshworroy7396
    @eshworroy7396 Месяц назад

    good explaination

  • @ayushnautiyal7965
    @ayushnautiyal7965 Год назад +3

    Congrats for becoming Expert again

  • @astroflexx82
    @astroflexx82 Год назад

    Very clear and concise explanation sir!

  • @azizkamri8019
    @azizkamri8019 Год назад

    can you make video on codechef starter 80 problem name- "Three People Contest"

  • @MohdAsim-ur5pf
    @MohdAsim-ur5pf Год назад +1

    Use this code to find the value of j . It'll be quite easy ....
    for( ...){
    j = findLeastPossible(0, i, i, a);
    ....
    }
    ll findLeastPossible(int L, int R, int cur, ll *a)
    {
    ll ans = INT_MIN;
    while (L = cur - mid + 1)
    {
    ans = mid;
    R = mid - 1;
    }
    else
    {
    L = mid + 1;
    }
    }
    return ans;
    }

  • @nikhilkumarv2577
    @nikhilkumarv2577 Год назад

    🛐

  • @ShyamSundar-fx8gp
    @ShyamSundar-fx8gp Год назад

    Sir aapki videos kyu nhi aari hai ??? from past 3 weeks

  • @imstupid-sw1wk
    @imstupid-sw1wk Год назад

    Where is the code ? I'm having trouble implementing the code

  • @LoneWolf-tz6gq
    @LoneWolf-tz6gq Год назад +2

    Your approach was pretty good however i found this solution on codeforces too and i wanna know how this is working
    #include
    using namespace std;
    typedef long long ll;
    #define pb push_back
    #define rep(i, a, b) for (ll i = a; i < b; i++)
    #define eq(i, a, b) for (ll i = a; i > n;
    vec arr(n);
    rep(j, 0, n)
    {
    cin >> arr[j];
    }
    queue q;
    rep(j,0,n)
    {
    q.push(arr[j]);
    while (q.front()

    • @ADITYAKUMAR-tb4gm
      @ADITYAKUMAR-tb4gm Год назад +2

      Given array is already sorted ( as given in question) , so elements on right are bigger than elements on left in any sequence. To make score max possible , if you want to include an element , it will increase sequence length by 1 , thus d' = d*Length
      d' is new denominator and d is old denominator. (This is how factorial works n! = n*(n-1)!)
      This element multiplied in numerator must be >= length after including it, otherwise answer will decrease which we don't want.
      As array is sorted, leftmost element will be smallest one , thus we can check if its smaller than total length of current sequence , and if it's decrease length by removing it.

    • @LoneWolf-tz6gq
      @LoneWolf-tz6gq Год назад

      @@ADITYAKUMAR-tb4gm GOT IT , THANKS!