Note that there are some explanatory texts on larger screens.

plurals
  1. POThe puzzle of Liars
    primarykey
    data
    text
    <p>I have been trying to solve a puzzle in <a href="https://www.interviewstreet.com/challenges/dashboard/#problem/4f9ea7df7d5c6" rel="nofollow">Interviewstreet</a>. But I don't have a clue for the problem by now. It'll be great if someone can give me a hint.</p> <p>The puzzle is: You have N soldiers numbered from 1 to N. Each of your soldiers is either a liar or a truthful person. You have M sets of information about them. The information is of the following form:</p> <p>Each line contains 3 integers - A, B and C. This means that in the set of soldiers numbered as {A, A+1, A+2, ..., B}, exactly C of them are liars. There are M lines like the above.</p> <p>Let L be the total number of your liar soldiers. Since you can't find the exact value of L, you want to find the minimum and maximum value of L.</p> <p>Input:</p> <p>The first line of the input contains two integers N and M. Each of next M lines contains three integers - A, B and C (1 &lt;= Ai &lt;= Bi &lt;= n) and (0 &lt;= Ci &lt;= Bi-Ai). where Ai, B i and C i refers to the values of A, B and C in the ith line respectively N and M are not more than 101, and it is guaranteed the given informations are satisfiable. You can always find a situation that satisfies the given information .</p> <p>Output:</p> <p>Print two integers Lmin and Lmax to the output.</p> <p>Sample Input</p> <pre><code>3 2 1 2 1 2 3 1 </code></pre> <p>Sample Output</p> <pre><code>1 2 </code></pre> <p>Sample Input</p> <pre><code>20 11 3 8 4 1 9 6 1 13 9 5 11 5 4 19 12 8 13 5 4 8 4 7 9 2 10 13 3 7 16 7 14 19 4 </code></pre> <p>Sample Output</p> <pre><code>13 14 </code></pre> <p>Explanation</p> <p>In the first sample testcase the first line is "3 2", meaning that there are 3 soldiers and we have two sets of information. The first information is that in the set of soldiers {1, 2} one is a liar and the second piece of information is that in the set of soldiers {2,3} again there is one liar. Now there are two possibilities for this scenario: Soldiers number 1 and 3 are liars or soldier number 2 is liar. So the minimum number of liars is 1 and maximum number of liars is 2. Hence the answer, 1 2.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload