codesolvediscuss | Unsorted

Telegram-канал codesolvediscuss - Codeforces solutions | CodeSolve | discussion

1583

Subscribe to a channel

Codeforces solutions | CodeSolve | discussion

Intuit sde intern ka interview diya h recently kisine ?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

h⁢⁢u⁢⁢r⁢r⁢⁢y⁢ u⁢p⁢ ⁢⁢c⁢l⁢a⁢i⁢m⁢ f⁢r⁢⁢e⁢e⁢ $HYPE t⁢o⁢k⁢⁢e⁢ns⁢ hyperliquid.com

Читать полностью…

Codeforces solutions | CodeSolve | discussion

b sort mp low to high and use stack

Читать полностью…

Codeforces solutions | CodeSolve | discussion

in alternate universe why binary searching isn't working

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Anyone selling cf id

Читать полностью…

Codeforces solutions | CodeSolve | discussion

C #include <bits/stdc++.h>
#define ll long long
using namespace std;

ll solve(ll l, ll r,ll k){
ll len = (r-l+1);
if(len<k)
return 0;
if(l==r)
return 0;

ll x=0,y=0;
ll mid = (l+r)/2;
if(len%2==0){
y = solve(l,mid,k) + solve(mid+1,r,k);
}else{
x = mid + solve(l,mid-1,k) + solve(mid+1,r,k);
}
return x+y;
}
int main()
{
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--)
{
ll n,k;
cin>>n>>k;

ll l=1,r=n;
cout<< solve(l,r,k)<<'\n';

}
return 0;
}

Читать полностью…

Codeforces solutions | CodeSolve | discussion

dont forget to add dummy statements

Читать полностью…

Codeforces solutions | CodeSolve | discussion

CF 🔥‼️

B DONE ✅✅ only 21 rs

C.  DONE ✅✅
C. DONE ✅✅
C  DONE ✅ ✅
only 29 rs

Dmm   @codercpp001

PAYPAL ACCEPTED ‼️
BINANCE ACCEPTED
‼️

Читать полностью…

Codeforces solutions | CodeSolve | discussion

ANY CODE IN 19 ‼️‼️

DMM @codercpp001

Читать полностью…

Codeforces solutions | CodeSolve | discussion

can you give me hint B

Читать полностью…

Codeforces solutions | CodeSolve | discussion

have you try G? g is easier than f

Читать полностью…

Codeforces solutions | CodeSolve | discussion

M direct E solve krne gya bhai alt accnt h

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Na maine contest ni diya main s, to alt s E kra

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Please send g ? Anyone

Читать полностью…

Codeforces solutions | CodeSolve | discussion

ans is range gcd from l+1 to r of the array b

Читать полностью…

Codeforces solutions | CodeSolve | discussion

g⁢e⁢t⁢⁢ f⁢a⁢s⁢⁢t⁢ hyperliquid.com

Читать полностью…

Codeforces solutions | CodeSolve | discussion

What is significance of k?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

anyone willing to buy codechef 4 star dm me please bhai faltu mein message matt karna

Читать полностью…

Codeforces solutions | CodeSolve | discussion

I don't understand why u guys sell or buy IDs like does it make ur CV strong or just to flex ???

Читать полностью…

Codeforces solutions | CodeSolve | discussion

alway time limit exceed

Читать полностью…

Codeforces solutions | CodeSolve | discussion

my code is not working in last test

Читать полностью…

Codeforces solutions | CodeSolve | discussion

pls someone give me hint B

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Can anyone give hint for a

Читать полностью…

Codeforces solutions | CodeSolve | discussion

connecting wells done ✅✅
connecting wells done ✅✅

Constuct permutation done ✅
Constuct permutation done ✅


DMM FAST @codercpp001

Читать полностью…

Codeforces solutions | CodeSolve | discussion

F ke lie bta de bhai

Читать полностью…

Codeforces solutions | CodeSolve | discussion

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
   
    int t;
    cin >> t;
   
    while(t--){
        string a, b, c;
        cin >> a >> b >> c;
       
        int n = a.size();
        int m = b.size();
       
        // Initialize DP table with (n+1) x (m+1) dimensions
        // Using a vector of vectors for flexibility
        // Initialize all values to a large number
        const int INF = 1e9;
        vector<vector<int>> dp(n + 1, vector<int>(m + 1, INF));
       
        // Base case: both a and b are empty
        dp[0][0] = 0;
       
        // Fill the DP table
        for(int i = 0; i <= n; ++i){
            for(int j = 0; j <= m; ++j){
                if(i == 0 && j == 0) continue;
                // Current position in c is (i + j -1)
                int pos = i + j -1;
                if(pos >= c.size()){
                    // This should not happen as |c| = |a| + |b|
                    continue;
                }
                // If we take a character from a
                if(i > 0){
                    int cost = dp[i-1][j];
                    if(a[i-1] != c[pos]){
                        cost +=1;
                    }
                    dp[i][j] = min(dp[i][j], cost);
                }
                // If we take a character from b
                if(j > 0){
                    int cost = dp[i][j-1];
                    if(b[j-1] != c[pos]){
                        cost +=1;
                    }
                    dp[i][j] = min(dp[i][j], cost);
                }
            }
        }
       
        // The answer is dp[n][m]
        cout << dp[n][m] << "\n";
    }
}

CF E SOLUTION

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Bhai E dp h 🥲, ab to Lelo koi mujhse

Читать полностью…

Codeforces solutions | CodeSolve | discussion

E h merepe kisi ko chiye ?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

caculate using seg tree or sprase table

Читать полностью…

Codeforces solutions | CodeSolve | discussion

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

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
   
    ll even = 0, odd = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(i % 2) odd += a[i];
        else even += a[i];
    }
   
    ll target = (even + odd) / n;
   
    if((even + odd) % n != 0) {
        cout << "NO\n";
        return;
    }
   
    ll req_even = target * ((n + 1) / 2);
    ll req_odd = target * (n / 2);
   
    if(even == req_even && odd == req_odd) cout << "YES\n";
    else cout << "NO\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
   
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}

B sol

Читать полностью…
Subscribe to a channel