Deloitte | PWC | ATS resumes | Wipro | Infosys | Accenture | Capegemini | job links
Open in Telegram
WhatsApp group link https://chat.whatsapp.com/Il915UNLpw32YjwxFf8D63
Show more4 673
Subscribers
No data24 hours
-17 days
-630 days
Posts Archive
Guys registerš
Data Science using Python ā
ā
Data Science Career Opportunity
High chances of getting job referrals to students who register in this.
ā
Must Register as this is free of cost for the first time
Register Now for Free: https://bit.ly/47KtVSN
Cognizant help going on
Cognizant Exam
Tech Mahindra
IBM
Help available
Very Few slots left for Cognizant
100% Clearance Guarantee.
Contact @placementsBroš
For any exam
Pay nd book slot by before day
So that we can clear ā
ll help(ll ans,ll k,map,ll>&m){
//cout<=0;i--){
for(ll j=30;j>=0;j--){
ll k1=(ans|(1LL<a,ll k){
ll n=a.size();
ll ans=a[0];
for(ll i=1;i,ll>m;
cout<
import java.util.*
data class Node(val value: Int, val dist: Int)
const val INF = 1e9.toInt()
fun main() {
val n = readLine()!!.toInt()
val m = readLine()!!.toInt()
val A = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
val graph = List(n) { mutableListOf<Int>() }
val dist = List(n) { IntArray(n) { INF } }
repeat(n) {
A[it] = readLine()!!.toInt()
}
repeat(m) {
val (x, y) = readLine()!!.split(" ").map { it.toInt() - 1 }
graph[x].add(y)
graph[y].add(x)
dist[x][y] = 1
dist[y][x] = 1
}
for (k in 0 until n) {
for (i in 0 until n) {
for (j in 0 until n) {
dist[i][j] = minOf(dist[i][j], dist[i][k] + dist[k][j])
}
}
}
val pq = PriorityQueue<Node>(compareBy { it.dist })
for (i in 0 until n) {
if (A[i] > 0) {
pq.add(Node(i, 0))
}
}
var cost = 0L
while (pq.isNotEmpty()) {
val node = pq.poll()
val u = node.value
val d = node.dist
if (A[u] > 0) {
cost += d * A[u]
A[u] = 0
for (v in graph[u]) {
if (A[v] > 0) {
pq.add(Node(v, d + 1))
}
}
}
}
for (i in 0 until n) {
if (A[i] > 0) {
println(-n)
return
}
}
println(cost)
}
//tree=0
All passedā
import java.util.Scanner
const val MOD = 1000000007
fun countBeautifulSequences(n: Int): Int {
if (n == 1) {
return 1
}
val dp = IntArray(n + 1) { 0 }
dp[1] = 1
for (i in 1..n) {
for (j in i..n) {
dp[j] = (dp[j] + dp[j - i]) % MOD
}
}
return (dp[n] - 1 + MOD) % MOD
}
fun main() {
val scanner = Scanner(System.
in)
val n = scanner.nextInt()
val result = countBeautifulSequences(n)
println(result)
}
//CBSint solve(vector&arr)
{
if(arr.size()==1)
{
if(arr[0]==0)
return 0;
else
return 1;
}
int u=0;
int s=0;
int n=arr.size();
int r=0;
for(int i=0;is)
r+=i-s+1;
}
return 2*r;
}
int solve(vector&a) {
int n=a.size();
vector dp(1e5+1),d(1e5+1);
int ans = 0;
for (int i = 0;i
Next code is readyš
No one is sharing our group
I won't share codes
Guys we are
3126 members
Can't we make 3150
Family?
next Code code comes only at 3150 members š
https://t.me/infosys_codes
#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ā
All test cases passed šļøā¤ļø
Next code is ready
Add 20 more members enough
(Make 3150)
Share share
https://t.me/infosys_codes
Next code is ready
Add 20 more members enough
(Make 3150)
Share share
https://t.me/infosys_codes
Pls like this messageā
Who are sharing our group
