-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathques3.html
More file actions
137 lines (106 loc) · 5.23 KB
/
ques3.html
File metadata and controls
137 lines (106 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html>
<head>
<title> Ques3 </title>
<link href="style2.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript">
//disable right click
document.addEventListener('contextmenu', event => event.preventDefault());
//disable inspect shortcuts
document.onkeydown = function(e) {
if(event.keyCode == 123) {
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){
return false;
}
}
</script>
<script type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
window.onbeforeload = function() {return" Your work will be lost." ;};
var i=0;
function myfunc()
{
var a=document.myform.q1.value;
if(i<=3)
{
if(a=="55")
{ alert("You got it right " );
window.location.replace("pass3.html ");
}
else
{i++;
if(i==1)
{ alert("Two more Chances!" );
}
else if(i==2)
{ alert("One more chance!" );
}
}
}
else
{alert("All attempts are used !" );
window.location.replace(" attempts.html ");
}
}
</script>
<body onload="noBack();" onpageshow="if(event.persisted) noBack():" onunload="" ;
background="bgq4.gif">
<header>
<br>
<div class="headline">
<h1> <u> <br> Question 3 </u></h1>
</div>
<p> The planet Titan has the shape of a tree — there are N servers and N-1 bidirectional channels connecting pairs of servers in such a way that there is exactly one path between each pair of servers.
Each Titan citizen lives on exactly one server at any point in time. Each channel connecting two servers has a value called blip. Each citizen can move to a different server through channels; moving through
a channel with blip 2w takes w nanoseconds.
<br>Initially, there are ci citizens living on the i-th server (for each 1 ≤ i ≤ N).Recently, Thanos has created an Intitial Currency Offering for Titancoin — the
cryptocurrency of the future in Titan. Everyone in Titan should receive exactly 1 Titancoin.
<br>How to organize this process? Titancoins can only be received on certain servers containing cryptoexchanges. Unfortunately, Thanos can only create cryptoexchanges
on two servers, since they consume a lot of electric power. The citizens want to receive Titancoin as fast as possible; therefore, each citizen chooses the closest server with a cryptoexchange and moves to that server.
Receiving Titancoin at a cryptoexchange takes zero time.Thanos wants to minimize the sum of the times each citizen needs to spend moving to receive Titancoin. The two servers containing cryptoexchanges can be chosen
arbitrarily. Compute the minimum total time it takes Titan's citizens to receive Titancoin!
<br><br>Input
<br> The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
<br> The first line of each test case contains a single integer N.
<br> The second line contains N space-separated integers c1, c2, ..., cN.
<br>N-1 lines follow. Each of these lines contains three space-separated integers u, v and w denoting a channel with blip 2w nanoseconds connecting servers u and v.
<br><br>Output
<br>For each test case, print a single line containing one integer — the minimal sum of times it takes each citizen to receive Titancoin if the two cryptoexchanges are placed optimally.
<br><br>Constraints<br>
1 ≤ N ≤ 50000<br>
1 ≤ ci ≤ 50000 for each valid i<br>
1 ≤ w ≤ 50000<br>
1 ≤ u, v ≤ N<br>
the channels describe a tree<br>
1 ≤ sum of N over all test cases ≤ 250000<br>
If the Input is :<br>
1<br>
4<br>
10 25 15 40<br>
1 2 1<br>
2 3 3<br>
1 4 4<br>
What is the Output?
<form name= "myform" action=" " method="post">
<div>
<label for="Solution"> Solution </label>
<input type="text" autocomplete="off" name="q1">
</div>
<div>
<input type="button" class="submit" value="Submit" onclick="myfunc ()">
</div>
</form>
</p>
</header>
</body>
</html>