Codechef Starters 141 | Video Solutions - A to D | by Abhinav Kumar | TLE Eliminators

Поділитися
Вставка
  • Опубліковано 27 сер 2024

КОМЕНТАРІ • 23

  • @TLE_Eliminators
    @TLE_Eliminators  Місяць тому

    Please fill the feedback form: forms.gle/WdVAj6WUKMxkSbXF6

  • @c-fn5jv
    @c-fn5jv Місяць тому +5

    For problem C you can compute initial beauty in O(n) using pref sum

  • @adarshamit7860
    @adarshamit7860 Місяць тому +3

    i was able to do 2 of them... thanks for the explanation , it helps us upsolve our contests.

  • @pratyushdubey5362
    @pratyushdubey5362 Місяць тому +3

    Great explanation thanks alot to the TLE team 🙌.

  • @39_jatinjain4
    @39_jatinjain4 Місяць тому +2

    Great Explanation

  • @VivekYadav-uy9ts
    @VivekYadav-uy9ts Місяць тому +1

    Thnx for the explanations bro, they were great!

  • @NIKHIL-wh1qh
    @NIKHIL-wh1qh Місяць тому

    There is no need to use set we can check beauty by prefix sum if it is equal to i*(i+1)/2 or sum-arr[i]+arr[i+1] is equal to i*(i+1)/2 . This approach will solve the question in O(n) for question. 3

  • @nightfury6096
    @nightfury6096 Місяць тому +1

    great explanation💯

  • @user-qq5bb7bh5z
    @user-qq5bb7bh5z Місяць тому +1

    b and c explanation was so goood!!

    • @garvsharma1210
      @garvsharma1210 Місяць тому

      kuch bhi , b m formula kse aaya btaya hi nahi !!

  • @bishwathakur3600
    @bishwathakur3600 Місяць тому +1

    Lovely explanation sir🔥🔥🔥

  • @AbhishekKumar-xj5un
    @AbhishekKumar-xj5un Місяць тому

    In the first question if the array is [2 2 2 2 2 3 3 3 3 3 3] -> converting all elements to 2 would cost 6*2=12 and converting all elements to 3 would cost 5*3=15 , but instead we can convert all the elements to one and the cost would be 11 but your code would output 12 but the optimal is 11 please have a look.

    • @abhinavkumariitism
      @abhinavkumariitism Місяць тому +1

      I have checked *for every x from 1 to n* ,
      so when x=1, we get freq[x]=0, so (n-0)*1 is going to give me the optimal answer of 11 for the test case you mentioned.
      You can look at my code, i run a loop *for(int i=1;i

  • @sourabhbindal774
    @sourabhbindal774 Місяць тому +1

    Can someone pls tell why this code fails i have checked its the same logic
    #include
    using namespace std;
    typedef long long ll;
    const int dx[] = {1, -1, 0, 0};
    const int dy[] = {0, 0, 1, -1};
    const int mod = 1e9 + 7;
    int main() {
    // your code goes here
    int t;
    cin >> t;
    while(t--){
    int n;
    cin >> n;
    std::vector arr(n);
    vector mp(n+1);
    for(int i=0; i> arr[i];
    mp[arr[i]]++;
    }
    int ans = 1e9;
    for(int i=1; i

  • @pushkarraj4640
    @pushkarraj4640 Місяць тому

    In C why initial beauty + mx is the ans ? While swapping element in any subarray to get mx wouldn't the initial beauty will also get affected?

    • @VivekYadav-uy9ts
      @VivekYadav-uy9ts Місяць тому +1

      No, becuz we are also taking negative one (-1) in cosideration from 'vec' while finding 'mx' that's why the change you're talking about will also get counted while finding the 'mx' itself!

  • @yashmondal7125
    @yashmondal7125 Місяць тому +1

    The code for the second problem is not working : third output is coming in negative .... Can you provide the correct code !!

    • @abhinavkumariitism
      @abhinavkumariitism Місяць тому +1

      Use "long long"
      I have defined my int as long long, that's y its working.

    • @Tanishq_NITian
      @Tanishq_NITian Місяць тому

      #include
      using namespace std;
      typedef long long ll;
      const int MOD = 1e9 + 7;
      typedef vector vi;
      typedef vector vll;
      typedef vector vvi;
      typedef vector vs;
      typedef vector vvs;
      typedef pair pii;
      typedef vector vpii;
      int main()
      {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int t = 1;
      cin >> t;
      for (int i = 0; i < t; i++)
      {
      ll n, k, h;
      cin >> n >> k >> h;
      ll ans = 0;
      for (ll i = 1; i =h)
      ans += n;
      else
      {

      ll r = (k*a-h)/(k-1);
      if(r>0) ans+=r;

      }
      }
      cout

    • @shobhitsingh8695
      @shobhitsingh8695 Місяць тому

      i did it with binary search
      #include
      using namespace std;
      #define ll long long int
      bool canEscape(ll A, ll B, ll H, ll K) {
      if (A >= H) return true;
      if (A N >> K >> H;
      ll count = 0;
      ll low = 1;
      ll high = N;
      ll minA = 2;
      while (low

  • @deepanshuchawla6493
    @deepanshuchawla6493 Місяць тому

    July batch kab launch hoga?

  • @ravishsingla4454
    @ravishsingla4454 Місяць тому

    bhai sab kuch bdia h bas network sahi karlo voice bhot break ho rhi