You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p><em>Single Round Match 584 Round 1 - Division I, Level One</em></p>
9
+
10
+
<h2>Statement</h2>
11
+
12
+
<p>A kingdom has n citizens. Each one has some amount of money, a number of dollars denoted by a non-negative integer.</p>
13
+
14
+
<p>Citizens are numbered from 0 to n-1. Some citizens have friends. Their friendship network is described by a String[] called <em>isFriend</em>, such that if <em>isFriend</em>[i][j] == 'Y', the citizens numbered i and j are friends, and if <em>isFriend</em>[i][j] == 'N', these citizens are not friends.</p>
15
+
16
+
<p>The king decrees the following:</p>
17
+
18
+
<p>Each citizen's amount of money must be within <em>d</em> dollars of the amount of money belonging to any of his friends. In other words, a citizen with x dollars must not have any friends with less than x-<em>d</em> dollars or more than x+<em>d</em> dollars.</p>
19
+
20
+
<p>Given the number of citizens and their friendship network, what is the greatest possible money difference between any two people (not necessarily friends) in this kingdom? If there is a finite answer, return it. Otherwise, return -1.</p>
<p>The kingdom has three citizens. Citizens 0 and 1 are friends. Also, citizens 1 and 2 are friends. The greatest possible money difference between any two citizens is $20, as in the following configuration: citizen 0 has $100; citizen 1 has $110; citizen 2 has $120.</p>
60
+
61
+
<h3>Example 2</h3>
62
+
63
+
<h4>Input</h4>
64
+
65
+
<p><c>["NN",<br/> "NN"],<br/>1</c></p>
66
+
67
+
<h4>Output</h4>
68
+
69
+
<p><c>-1</c></p>
70
+
71
+
<h4>Reason</h4>
72
+
73
+
<p>Since citizens 0 and 1 are not friends, there are no constraints between them.</p>
0 commit comments