# SUBREM - Editorial

WHY K IS always 1 .in every solution -x use.it mean k is always 1.

can anybody tell me why im getting wrong answer
/* package codechef; // don’t place package name! */

import java.io.;
import java.util.
;

/* Name of the class has to be “Main” only if the class is public. */
class Temp {

``````static int cost;

static class Node {
int vertex, value;

public Node(int vertex, int value) {
this.vertex = vertex;
this.value = value;
}
}

static class Graph {

private int v;
private boolean[] visited;

Graph(int v) {
this.v = v;
adjList = new ArrayList[v + 1];
for (int i = 1; i <= v; i++) {
}
}

void addEdge(int u, Node node) {
}

long dfs(Node root) {
visited = new boolean[v + 1];
return dfsHelper(root);
}

long dfsHelper(Node node) {
visited[node.vertex] = true;
long total_profit = 0;
for (Node neigbour : adjList[node.vertex]) {
if (!visited[neigbour.vertex]) {
total_profit += dfsHelper(neigbour);
}
}
return Math.max(total_profit + node.value, -cost);
}
}

public static void main(String[] args) throws IOException {
StringTokenizer st;
StringBuilder sb = new StringBuilder();
while (t-- > 0) {
int n = Integer.parseInt(st.nextToken());
cost = Integer.parseInt(st.nextToken());

int[] a = new int[n+1];
Graph g = new Graph(n);

for (int i = 1; i <= n; i++) {
a[i] = Integer.parseInt(st.nextToken());
}

int u, v;
for (int i = 1; i < n; i++) {