{"id":298543,"date":"2020-02-11T21:00:08","date_gmt":"2020-02-11T21:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298543"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298543","title":{"rendered":"\u0412\u044b\u043f\u0443\u0441\u043a#30: IT\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0430 \u2014 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0442 \u0432\u0435\u0434\u0443\u0449\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/486506\/\">\u041f\u0440\u0438\u0432\u0435\u0442! \u0410 \u0432\u043e\u0442 \u0438 \u043c\u044b! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0443 \u043d\u0430\u0441 \u044e\u0431\u0438\u043b\u0435\u0439\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 30!<br \/>  \u041c\u044b \u0432\u043d\u043e\u0432\u044c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0412\u0430\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0437\u0430\u0434\u0430\u0447\u0435\u043a \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 IT-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438! \u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0443\u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/484276\/\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yc\/wg\/n_\/ycwgn_fvmbucsgxvr2wl0dj613q.png\"><\/p>\n<p>  \u0412\u044b\u043f\u0443\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u2014 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438! \u0420\u0443\u0431\u0440\u0438\u043a\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0440\u0435\u043a\u0440\u0443\u0442\u0438\u043d\u0433\u043e\u0432\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 <a href=\"http:\/\/www.spice-agency.ru\/ru\/\">Spice IT<\/a>.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0430\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u0443\u044e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e Visa.<a name=\"habracut\"><\/a><\/p>\n<h2>\u0412\u043e\u043f\u0440\u043e\u0441\u044b<\/h2>\n<p>  1. <b>100 Prisoners with Red\/Black Hats<\/b>  <\/p>\n<blockquote><p>100 prisoners in jail are standing in a queue facing in one direction. Each prisoner is wearing a hat of color either black or red. A prisoner can see hats of all prisoners in front of him in the queue, but cannot see his hat and hats of prisoners standing behind him.<br \/>  The jailer is going to ask color of each prisoner\u2019s hat starting from the last prisoner in queue. If a prisoner tells the correct color, then is saved, otherwise executed. How many prisoners can be saved at most if they are allowed to discuss a strategy before the jailer starts asking colors of their hats.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">100 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0442\u044e\u0440\u044c\u043c\u0435 \u0441\u0442\u043e\u044f\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043b\u0438\u0446\u043e\u043c \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u043d\u043e\u0441\u0438\u0442 \u0448\u0430\u043f\u043a\u0443 \u0447\u0435\u0440\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0448\u0430\u043f\u043a\u0438 \u0432\u0441\u0435\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043d\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0432\u043e\u044e \u0448\u0430\u043f\u043a\u0443 \u0438 \u0448\u0430\u043f\u043a\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445, \u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u043f\u043e\u0437\u0430\u0434\u0438 \u043d\u0435\u0433\u043e.<br \/>  \u0422\u044e\u0440\u0435\u043c\u0449\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442 \u0448\u0430\u043f\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0415\u0441\u043b\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0442\u043e \u0435\u0433\u043e \u043f\u043e\u043c\u0438\u043b\u0443\u044e\u0442, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u0430\u0437\u043d\u044f\u0442. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u0430\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0438\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0442\u044e\u0440\u0435\u043c\u0449\u0438\u043a \u043d\u0430\u0447\u043d\u0435\u0442 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442\u0430 \u0441\u0432\u043e\u0438\u0445 \u0448\u043b\u044f\u043f.<br \/>  \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u0435 \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e.<\/div>\n<\/div>\n<p>  2. <b>Ratio of Boys and Girls in a Country where people want only boys<\/b>  <\/p>\n<blockquote><p>In a country, all families want a boy. They keep having babies till a boy is born. What is the expected ratio of boys and girls in the country?<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0412 \u0441\u0442\u0440\u0430\u043d\u0435 \u0432\u0441\u0435 \u0441\u0435\u043c\u044c\u0438 \u0445\u043e\u0442\u044f\u0442 \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u0430. \u041e\u043d\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0440\u043e\u0436\u0430\u0442\u044c \u0434\u0435\u0442\u0435\u0439 \u0434\u043e \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u0430. \u041a\u0430\u043a\u043e\u0432\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u0432 \u0438 \u0434\u0435\u0432\u043e\u0447\u0435\u043a \u0432 \u0441\u0442\u0440\u0430\u043d\u0435?<\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>  1. <b>The Lazy Caterer&#8217;s Problem<\/b>  <\/p>\n<blockquote><p>Given an integer <b>N<\/b>, denoting the number of cuts that can be made on a pancake, find the maximum number of pieces that can be formed by making <b>N<\/b> cuts.<\/p>\n<p>  <b>Input:<\/b><br \/>  The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of one line. The first line of each test case consists of an integer N.<\/p>\n<p>  <b>Output:<\/b><br \/>  Corresponding to each test case, in a new line, print the maximum number of pieces that can be formed by making N cuts.<\/p>\n<p>  <b>Constraints:<\/b><\/p>\n<p>  <code>1 \u2264 T \u2264 100<br \/>  1 \u2264 N \u2264 106<\/code><\/p>\n<p>  <b>Example:<br \/>  Input<\/b><br \/>  <code>2<br \/>  5<br \/>  3<\/code><br \/>  <b>Output<\/b><br \/>  <code>16<br \/>  7<\/code><\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e <b>N<\/b>, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0431\u043b\u0438\u043d\u0435. \u041d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0441\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0441\u0434\u0435\u043b\u0430\u0432 <b>N<\/b> \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432.<\/p>\n<p>  <b>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/b><br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0432\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e T, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0442\u0435\u0441\u0442\u044b T. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 N.<\/p>\n<p>  <b>\u0412\u044b\u0445\u043e\u0434:<\/b><br \/>  \u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0432 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u0442\u0430\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f N \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432.<\/p>\n<p>  <b>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/b><\/p>\n<p>  <code>1 \u2264 T \u2264 100<br \/>  1 \u2264 N \u2264 106<\/code><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  \u0412\u0445\u043e\u0434<\/b><br \/>  <code>2<br \/>  5<br \/>  3<\/code><br \/>  <b>\u0412\u044b\u0445\u043e\u0434<\/b><br \/>  <code>16<br \/>  7<\/code><\/div>\n<\/div>\n<p>  2. <b>Peak element<\/b>  <\/p>\n<blockquote><p>Given an array A of N integers. The task is to find a peak element in it.<br \/>  An array element is peak if it is not smaller than its neighbours. For corner elements, we need to consider only one neighbour.<\/p>\n<p>  <b>Note: <\/b>There may be multiple peak element possible, in that case you may return any valid index.<\/p>\n<p>  <b>Input Format:<\/b><br \/>  The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N. Then in the next line are N space separated values of the array.<\/p>\n<p>  <b>Output Format:<\/b><br \/>  For each test case output will be 1 if the index returned by the function is an index with peak element.<\/p>\n<p>  <b>User Task:<\/b><br \/>  You don&#8217;t have to take any input. Just complete the provided function peakElement() and return the valid index.<\/p>\n<p>  <b>Constraints:<\/b><br \/>  <code>1 &lt;= T &lt;= 100<br \/>  1 &lt;= N &lt;= 100<br \/>  1 &lt;= A[] &lt;= 1000<\/code><\/p>\n<p>  <b>Example:<br \/>  Input:<\/b><br \/>  <code>2<br \/>  3<br \/>  1 2 3<br \/>  2<br \/>  3 4<\/code><br \/>  <b>Output:<\/b><br \/>  <code>3<br \/>  4<\/code><\/p>\n<p>  <b>Explanation:<br \/>  Testcase 1: <\/b>In the given array, 3 is the peak element.<br \/>  <b>Testcase 2: <\/b>4 is the peak element.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430\u043d \u043c\u0430\u0441\u0441\u0438\u0432 A \u0438\u0437 N \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432 \u043d\u0435\u043c \u043f\u0438\u043a\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<br \/>  \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0438\u043a\u043e\u0432\u044b\u043c, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0432\u043e\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0414\u043b\u044f \u0443\u0433\u043b\u043e\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0430.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u043a\u043e\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<p>  <b>\u0424\u043e\u0440\u043c\u0430\u0442 \u0432\u0432\u043e\u0434\u0430:<\/b><br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0432\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e T, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0442\u0435\u0441\u0442\u044b T. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e N. \u0417\u0430\u0442\u0435\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f N \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>  <b>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/b><br \/>  <code>1 &lt;= T &lt;= 100<br \/>  1 &lt;= N &lt;= 100<br \/>  1 &lt;= A [] &lt;= 1000<\/code><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/b><br \/>  <code>2<br \/>  3<br \/>  1 2 3<br \/>  2<br \/>  3 4<\/code><br \/>  <b>\u0412\u044b\u0445\u043e\u0434:<\/b><br \/>  <code>3<br \/>  4<\/code><\/p>\n<p>  <b>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435:<br \/>  \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 1:<\/b> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435 3 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0438\u043a\u043e\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c.<br \/>  <b>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 2:<\/b> 4 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0438\u043a\u043e\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c.<\/div>\n<\/div>\n<p>  3. <b>Maximum Intervals Overlap<\/b>  <\/p>\n<blockquote><p>Consider a big party where a log register for guest\u2019s entry and exit times is maintained. Find the time at which there are maximum guests in the party. Note that entries in register are not in any order.<\/p>\n<p>  <b>Input:<\/b><br \/>  The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the entry and exit array. Then the next two line contains the entry and exit array respectively.<\/p>\n<p>  <b>Output:<\/b><br \/>  Print the maximum no of guests and the time at which there are maximum guests in the party.<\/p>\n<p>  <b>Constraints:<\/b><br \/>  <code>1&lt;=T&lt;=10^5<br \/>  1&lt;=N&lt;=10^5<br \/>  1&lt;=entry[i],exit[i]&lt;=10^5<\/code><\/p>\n<p>  <b>Example:<br \/>  Input:<\/b><br \/>  <code>2<br \/>  5<br \/>  1 2 10 5 5<br \/>  4 5 12 9 12<br \/>  7<br \/>  13 28 29 14 40 17 3 <br \/>  107 95 111 105 70 127 74 <\/code><\/p>\n<p>  <b>Output:<\/b><br \/>  <code>3 5<br \/>  7 40<\/code><\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0435\u0447\u0435\u0440\u0438\u043d\u043a\u0443, \u0433\u0434\u0435 \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0436\u0443\u0440\u043d\u0430\u043b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u0433\u043e\u0441\u0442\u044f. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0433\u043e\u0441\u0442\u044f\u0445 \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0433\u043e\u0441\u0442\u0435\u0439. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u043d\u0435 \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<p>  <b>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/b><br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0432\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e T, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0442\u0435\u0441\u0442\u044b T. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e n, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430. \u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  <b>\u0412\u044b\u0445\u043e\u0434:<\/b><br \/>  \u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0441\u0442\u0435\u0439 \u0438 \u0432\u0440\u0435\u043c\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u0432\u0435\u0447\u0435\u0440\u0438\u043d\u043a\u0435.<\/p>\n<p>  <b>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/b><br \/>  <code>1 &lt;= \u0422 &lt;= 10 ^ 5<br \/>  1 &lt;= N &lt;= 10 ^ 5<br \/>  1 &lt;= \u0437\u0430\u043f\u0438\u0441\u044c [I], \u0432\u044b\u0445\u043e\u0434 [I] &lt;= 10 ^ 5<\/code><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/b><br \/>  <code>2<br \/>  5<br \/>  1 2 10 5 5<br \/>  4 5 12 9 12<br \/>  7<br \/>  13 28 29 14 40 17 3<br \/>  107 95 111 105 70 127 74<\/code><\/p>\n<p>  \u0412\u044b\u0445\u043e\u0434:<br \/>  <code>3 5<br \/>  7 40<\/code><\/div>\n<\/div>\n<p>  \u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0430\u043d\u044b \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0438 \u2014 \u0443\u0441\u043f\u0435\u0439\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c. \u0423\u0434\u0430\u0447\u0438!<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/486506\/\"> https:\/\/habr.com\/ru\/company\/spice\/blog\/486506\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/486506\/\">\u041f\u0440\u0438\u0432\u0435\u0442! \u0410 \u0432\u043e\u0442 \u0438 \u043c\u044b! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0443 \u043d\u0430\u0441 \u044e\u0431\u0438\u043b\u0435\u0439\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 30!<br \/>  \u041c\u044b \u0432\u043d\u043e\u0432\u044c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0412\u0430\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0437\u0430\u0434\u0430\u0447\u0435\u043a \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 IT-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438! \u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0443\u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/484276\/\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yc\/wg\/n_\/ycwgn_fvmbucsgxvr2wl0dj613q.png\"><\/p>\n<p>  \u0412\u044b\u043f\u0443\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u2014 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438! \u0420\u0443\u0431\u0440\u0438\u043a\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0440\u0435\u043a\u0440\u0443\u0442\u0438\u043d\u0433\u043e\u0432\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 <a href=\"http:\/\/www.spice-agency.ru\/ru\/\">Spice IT<\/a>.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0430\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u0443\u044e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e Visa.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-298543","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=298543"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298543\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}