Coding | EXAMS | IBM ACCENTURE | VIRTUSA | IBM | AMAZON | TCS | EPAM | WILEY EDGE | TECH MAHINDRA | JPMORGAN | HCL | WIPRO
3.37K subscribers
1.13K photos
3 videos
17 files
373 links
Main channel https://t.me/Coding_000
Contact Admin 👉 @ILOVEU_143 for booking your exam slots
Web- https://coding000.github.io/Projects/
💯% clearance in any placement exams
OffCampus -https://t.me/Offcampus_000
Discussion- https://t.me/exams_discussion
Download Telegram
Guys share the screenshot in large groups and Share with your friends 🔥 @Coding_000 ❤️

I don't see anyone sharing 🥲
4
#include<bits/stdc++.h>
using namespace std;
const int N=500005;
typedef long long ll;
int T,n,k,t,h[N];
ll dp[N][2];
struct edge{
  int ver,net;
  ll val;
}f[N*2];
void add(int x,int y,int z){
  f[++t].net=h[x];
  h[x]=t,f[t].ver=y;
  f[t].val=z;
}
void dfs(int x,int fa){
  dp[x][0]=dp[x][1]=0;
  priority_queue<ll> q;
  for(int i=h[x];i;i=f[i].net){
    int y=f[i].ver;
    if(y==fa) continue;
    dfs(y,x);
    dp[x][0]+=dp[y][0];
    q.push(dp[y][1]+f[i].val-dp[y][0]);
  }
  dp[x][1]=dp[x][0];
  int p=k;
  while(p--&&q.size()&&q.top()>0){
    if(p) dp[x][1]+=q.top();
    dp[x][0]+=q.top();
    q.pop();
  }
 
}
int main(){
  scanf("%d",&T);
  while(T--){
    int x,y,z;t=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<n;++i){
      scanf("%d%d%d",&x,&y,&z);
      add(x,y,z),add(y,x,z);
    }
    dfs(1,0);
    printf("%lld\n",dp[1][0]);
    for(int i=1;i<=n;++i) h[i]=0,dp[i][0]=dp[i][1]=0;
  }
  return 0;
}
// Good edges

Share @coding_000❤️
👍4
He share our channel to Friends Now I am giving Free solution

All test cases pass

Share @Coding_000❤️
2👍1🥰1
DM @ILOVEU_143 ❤️

Send me our channel screenshot

Send ur questions i will send solutions

Dm Me Fast @ILOVEU_143❤️

Share @Coding_000❤️👨‍💻
👍3
Dm @ILOVEU_143


For Coding Help or Any Exam Help
😄


💯 Clearance

Check the previous proofs 👆👆

Share @Coding_000❤️
1👍1🔥1
Dm @ILOVEU_143


For Coding Help or Any Exam Help
😄


💯 Clearance

Check the previous proofs 👆👆

Share @Coding_000❤️
👍3
TECH Mahindra Exam

Round 2

Help available.👨‍💻

100% Clearance GUARANTEE.

Check our past Results. 👇👇

https://t.me/Coding_000/5567?single
https://t.me/Coding_000/5563?single

Contact
@ILOVEU_143
👍3
Say this with me:

I can make my dream life, career, and money real.

I have a plan, and it's happening now.

I'll achieve it, no matter what.

Never Give Up 😊

@OFFCAMPUS_000 ❤️
2🔥2🥰1
Dm @ILOVEU_143


For Coding Help or Any Exam Help
😄


💯 Clearance

Check the previous proofs 👆👆

Share @Coding_000❤️
👍2
SELECT
  id,
  title,
  s.quantity AS total_stock,
  r.quantity AS total_returns
  FROM
    products p
      LEFT JOIN stocks s
        ON p.id = s.product_id
      LEFT JOIN ( SELECT product_id, COUNT( * ) AS quantity FROM returns WHERE MONTHNAME( dt ) = 'July' GROUP BY product_id ) r
        ON p.id = r.product_id
  ORDER BY
    id

E-commerce sql
👍2
public static long getTriangleArea(List<Integer> x, List<Integer> y) {
        long area = (long) (0.5 * (x.get(0) * (y.get(1) - y.get(2)) + x.get(1) * (y.get(2) - y.get(0)) + x.get(2) * (y.get(0) - y.get(1))));
        return Math.abs(area);
    }
👍2