{"id":288844,"date":"2018-09-01T23:10:06","date_gmt":"2018-09-01T19:10:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=288844"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=288844","title":{"rendered":"\u0412\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438\u043b\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/422009\/\" class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f! \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0437 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b \u00ab\u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439\u00bb \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e \u0412\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438 \u043a\u0430\u043a \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0442\u0435\u043e\u0440\u0438\u0438 \u043f\u0440\u043e \u0442\u043e, \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438 \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0435\u0433\u043e \u043d\u0430 \u043c\u043d\u043e\u044e \u0432\u044b\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0438 \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u043c \u043d\u0430\u0431\u0440\u043e\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0430 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-_\/br\/t9\/-_brt9eary_qbrmnem54sxqslle.jpeg\" alt=\"image\"><br \/>  <a name=\"habracut\"><\/a><\/p>\n<h3>\u041f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e \u043c\u0435\u0442\u043e\u0434\u0435<\/h3>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0441 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043c\u0438 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0430\u0440\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u0438 \u044f \u0434\u0443\u043c\u0430\u044e \u0412\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0439\u043c\u0435\u0442\u0435 \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0412\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<ul>\n<li>\u0417\u0430\u0434\u0430\u0447\u0430 \u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u0438. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043b\u0430\u0441\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u0438\u043b\u0438 \u0431\u044b\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443. <\/li>\n<li>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u0448\u0438\u043d \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0435\u043a\u0446\u0438\u0438. \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0448\u0438\u043d \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0431\u044b\u043b\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0431\u044b\u043b\u044c\u043d\u044b\u043c, \u0438\u043b\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b. <\/li>\n<li>\u0412\u044b\u0431\u043e\u0440 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0438 \u043f\u043e \u043e\u0446\u0435\u043d\u043a\u0430\u043c. \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0438\u0436\u0435.<\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0412\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0412\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043c\u043d\u043e\u0433\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0444\u0435\u0440\u0430\u0445 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u0438\u043d \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c (\u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043c\u0430\u0448\u0438\u043d\u0430, \u043e\u0440\u0443\u0434\u0438\u0435, \u2026) \u043c\u043e\u0433 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0440\u0430\u0431\u043e\u0442\u0443, \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0435\u043c.<\/p>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u2013 \u044d\u0442\u043e \u0435\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0438\u043f. \u0422.\u0435. \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0435\u0439 = \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0431\u043e\u0442 (N=M). \u0415\u0441\u043b\u0438 \u0436\u0435 \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0435\u0439, \u0438\u043b\u0438 \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438. \u041d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u044d\u0442\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442, \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u0434\u0430\u0441\u0442 \u0435\u0439 \u0442\u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0438\u043f.<\/p>\n<h3>Step-by-step \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435<\/h3>\n<p>  <b>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438:<\/b> \u041f\u0443\u0441\u0442\u044c \u043d\u0430\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u043d\u0430\u0443\u0447\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044f. \u0414\u043b\u044f \u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0437\u0432\u0443\u043a, \u0441\u0432\u0435\u0442, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0441\u0442\u0435\u0439 \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u0435\u0440\u0435\u0440\u044b\u0432\u0430\u043c \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0435\u0441\u0442\u044c 5 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0438\u043c\u0435\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043e\u0446\u0435\u043d\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u043e\u0439, \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b (\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e \u043e\u0442\u0437\u044b\u0432\u0430\u043c \u0438\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432). \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0438\u0445 \u043e\u0446\u0435\u043d\u043a\u0430 \u0431\u044b\u043b\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439. \u0417\u0430\u0434\u0430\u0447\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oy\/a0\/ac\/oya0acblios9kph6xr3jpxw7-1k.png\" alt=\"image\"><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c (\u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435), \u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0435\u0433\u043e \u0436\u0435 \u0432\u044b\u0447\u0435\u0441\u0442\u044c \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043d\u0430 -1. \u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u0442\u043e \u044d\u0442\u043e\u0442 \u0448\u0430\u0433 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/um\/ug\/y0\/umugy08323i3c0csgbgr0odbrxy.png\" alt=\"image\"><\/div>\n<p>  \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043d\u043e\u043b\u044c. (\u0442.\u0435. \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043d\u043e\u043b\u044c, \u0442\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0443\u043b\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0435\u0440\u0435\u043c \u0432 \u0440\u0430\u0441\u0447\u0435\u0442). \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dx\/ub\/kr\/dxubkrwfd4dnp7oniivh1sh1az8.png\" alt=\"image\"><\/div>\n<p>  (<b>\u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 \u044d\u0442\u043e\u0433\u043e \u0448\u0430\u0433\u0430<\/b>). \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u0430\u043b\u0435\u0435. \u0420\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c (\u0438\u0449\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e):  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ih\/xr\/ev\/ihxrevbogoobr2xp-_9ckduuohi.png\" alt=\"image\"><\/div>\n<p>  \u0422.\u043a. \u0432\u0441\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u2013 \u043d\u0443\u043b\u0435\u0432\u044b\u0435, \u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c. \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0434\u0443\u043a\u0446\u0438\u044e \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qt\/kv\/7g\/qtkv7giyiwnyrc-2uxpd4bm-xq8.png\" alt=\"image\"><\/div>\n<p>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0431\u044b\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043d\u043e\u043b\u044c. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0438\u0436\u0435, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u043b\u0438, \u043d\u043e \u043d\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u0434\u0430\u043b \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/s2\/k_\/j6\/s2k_j6quvu-intdstmzwvo8uceu.png\" alt=\"image\"><\/div>\n<p>  \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u0430\u043b\u044c\u0448\u0435. \u0412\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b (<b>\u0412\u0410\u0416\u041d\u041e! \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c<\/b>). \u0421\u0440\u0435\u0434\u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0449\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439, \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u0437 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0437\u0430\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044b) \u0438 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0432\u044b\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 (\u0442\u043e, \u0447\u0442\u043e \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0437\u0435\u043b\u0435\u043d\u044b\u043c \u2013 \u0442\u0430\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c; \u0442\u043e, \u0447\u0442\u043e \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0437\u043e\u043b\u043e\u0442\u0438\u0441\u0442\u044b\u043c \u2013 \u0442\u0430\u043c \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c; \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u0437\u0430\u043a\u0440\u0430\u0448\u0435\u043d\u043e \u2013 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u043c):  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lj\/pg\/0u\/ljpg0usgtg-ojwfutmplp5ekh6m.png\" alt=\"image\"><\/div>\n<p>  \u041a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0438\u0434\u043d\u043e, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0438 \u0441\u0442\u0440\u043e\u043a\u0435 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043d\u043e\u043b\u044c. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c!  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/du\/u6\/_i\/duu6_i8kbygzae1gnomkqg_cr4w.png\" alt=\"image\"><\/div>\n<p>  \u041f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u0435\u0441\u0442\u043e\u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u043b\u0435\u0439. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0443\u043c, \u0438\u043b\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u0430\u043d, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043c \u0438 \u0441\u0443\u043c\u043c\u0430 \u043e\u0446\u0435\u043d\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/za\/eg\/ik\/zaegikyvmeq5lhcrs6tqqfu1mzk.png\" alt=\"image\"><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0443 \u0432\u0430\u0441 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u043b\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0438 \u0441\u0442\u0440\u043e\u043a\u0435 \u0431\u044b\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d, \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441 \u0442\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0433\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0440\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435)<\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f R<\/h3>\n<p>  \u0412\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0439. \u0411\u0443\u0434\u0443 \u043d\u0430\u0434\u0435\u044f\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u043c\u043e\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0440\u0430\u0441\u0447\u0435\u0442\u044b.<br \/>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 example.csv \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ts\/ku\/4f\/tsku4fw1v-tt81q0zufifqq9p_g.png\" alt=\"image\"><\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u0441\u043f\u043e\u0439\u043b\u0435\u0440 \u0438\u0431\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u0431\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0437-\u0437\u0430 \u043d\u0435\u0433\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 library(dplyr)  #\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c csv \u0444\u0430\u0438\u043b (\u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0438\u043a - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a; \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432) table &lt;- read.csv(\"example.csv\",header=TRUE,row.names=1,sep=\";\")  #\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0440\u0430\u0441\u0447\u0435\u0442\u044b unique_index &lt;- hungarian_algorithm(table,T)  #\u0412\u044b\u0432\u043e\u0434\u0438\u043c cat(paste(row.names(table[as.vector(unique_index$row),]),\" - \",names(table[as.vector(unique_index$col)])),sep = \"\\n\")  #\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u0430\u043d cat(\"\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 -\",sum(mapply(function(i, j) table[i, j], unique_index$row, unique_index$col, SIMPLIFY = TRUE)))    #____________________\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430__________________________________  hungarian_algorithm &lt;- function(data,optim=F){    #\u0415\u0441\u043b\u0438 optim = T, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435   if(optim==T)   {     data &lt;- data %&gt;%        apply(1,function(x) (x-max(x))*(-1)) %&gt;%        t() %&gt;%        as.data.frame()     optim &lt;- F   }    #\u0420\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c   data &lt;- data %&gt;%     apply(1,function(x) x-min(x)) %&gt;%      t() %&gt;%      as.data.frame()    #\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432\u0441\u0435\u0445 \u043d\u0443\u043b\u0435\u0439   zero_index &lt;- which(data==0, arr.ind = T)    #\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439 \u0441\u043b\u0435\u0432\u0430-\u043d\u0430\u043f\u0440\u0430\u0432\u043e   unique_index &lt;- from_the_beginning(zero_index)    #\u0415\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439 \u043d\u0435 \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0442\u043e..   if(nrow(unique_index)!=nrow(data)) #..\u0418\u0449\u0435\u043c \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f\" \u043d\u0443\u043b\u0438 \u0441\u043f\u0440\u0430\u0432\u0430-\u043d\u0430\u043b\u0435\u0432\u043e     unique_index &lt;- from_the_end(zero_index)    #\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f, \u0442\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u0430\u043b\u044c\u0448\u0435   if(nrow(unique_index)!=nrow(data))   {      #\u0420\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c     data &lt;- data %&gt;%       apply(2,function(x) x-min(x)) %&gt;%        as.data.frame()          zero_index &lt;- which(data==0, arr.ind = T)     unique_index &lt;- from_the_beginning(zero_index)          if(nrow(unique_index)!=nrow(data))       unique_index &lt;- from_the_end(zero_index)          if(nrow(unique_index)!=nrow(data))     {        #\"\u0412\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u043c\" \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b (\u0412\u0410\u0416\u041d\u041e! \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c)       index &lt;- which(apply(data,1,function(x) length(x[x==0])&gt;1))       index2 &lt;- which(apply(data[-index,],2,function(x) length(x[x==0])&gt;0))        #\u0421\u0440\u0435\u0434\u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0449\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439       min_from_table &lt;- min(data[-index,-index2])        #\u0412\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0437 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432       data[-index,-index2] &lt;- data[-index,-index2]-min_from_table        #\u041f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0432\u044b\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432       data[index,index2] &lt;- data[index,index2]+min_from_table              zero_index &lt;- which(data==0, arr.ind = T)       unique_index &lt;- from_the_beginning(zero_index)              if(nrow(unique_index)!=nrow(data))         unique_index &lt;- from_the_end(zero_index)        #\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439 \u043d\u0435 \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0442\u043e..       if(nrow(unique_index)!=nrow(data)) #..\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0432\u0435\u0441\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043d\u043e\u0432\u043e         hungarian_algorithm(data,optim)              else #\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439         unique_index     }     else #\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439       unique_index   }   else #\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439     unique_index } #_________________________________________________________________________________   #__________\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439 \u0441\u043b\u0435\u0432\u0430-\u043d\u0430\u043f\u0440\u0430\u0432\u043e___________  from_the_beginning &lt;- function(x,i=0,j=0,index = data.frame(row=numeric(),col=numeric())){    #\u0412\u044b\u0431\u043e\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0443\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043b\u0435\u0436\u0430\u0442 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 i, \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445 j   find_zero &lt;- x[(!x[,1] %in% i) &amp; (!x[,2] %in% j),]      if(length(find_zero)&gt;2){      #\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440     i &lt;- c(i,as.vector(find_zero[1,1]))    #\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440     j &lt;- c(j,as.vector(find_zero[1,2]))      #\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 data frame (\u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043d\u0443\u043b\u0435\u0439)     index &lt;- rbind(index,setNames(as.list(find_zero[1,]), names(index)))      #\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c     from_the_beginning(find_zero,i,j,index)}   else     rbind(index,find_zero) } #_________________________________________________________________________________  #__________\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \"\u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f\" \u043d\u0443\u043b\u0435\u0439 \u0441\u043f\u0440\u0430\u0432\u0430-\u043d\u0430\u043b\u0435\u0432\u043e___________  from_the_end &lt;- function(x,i=0,j=0,index = data.frame(row=numeric(),col=numeric())){   find_zero &lt;- x[(!x[,1] %in% i) &amp; (!x[,2] %in% j),]   if(length(find_zero)&gt;2){     i &lt;- c(i,as.vector(find_zero[nrow(find_zero),1]))     j &lt;- c(j,as.vector(find_zero[nrow(find_zero),2]))     index &lt;- rbind(index,setNames(as.list(find_zero[nrow(find_zero),]), names(index)))     from_the_end(find_zero,i,j,index)}   else     rbind(index,find_zero) } #_________________________________________________________________________________  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/77\/mc\/v8\/77mcv8tves2-yuyxpydtpzqdpi4.png\" alt=\"image\"><\/div>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jj\/b3\/tu\/jjb3tuqvhzyyd5vfwtqxyicpzk4.png\" alt=\"image\"><\/div>\n<h3>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0442\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043d\u0438\u0436\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0412\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u043e\u0432\u043e\u0435 \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u0441\u0442\u0430\u0440\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f. \u0412\u0441\u0435\u043c \u0443\u0441\u043f\u0435\u0445\u043e\u0432, \u0434\u043e\u0431\u0440\u0430 \u0438 \u0443\u0434\u0430\u0447\u0438!<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/h3>\n<p>  1. <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%92%D0%B5%D0%BD%D0%B3%D0%B5%D1%80%D1%81%D0%BA%D0%B8%D0%B9_%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC\">\u0428\u0442\u0443\u0440\u043c\u043e\u0432\u0430\u043b<\/a> <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B0_%D0%BE_%D0%BD%D0%B0%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D1%8F%D1%85\">\u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044e<\/a> <br \/>  2. <a href=\"https:\/\/math.semestr.ru\/nazn\/index.php\">\u0418<\/a> <a href=\"https:\/\/www.matburo.ru\/ex_mp.php?p1=mpnazn\">\u0434\u0440\u0443\u0433\u0438\u0435<\/a> <a href=\"https:\/\/studopedia.ru\/7_168439_vengerskiy-metod-resheniya-zadachi-o-naznacheniyah.html\">\u0445\u043e\u0440\u043e\u0448\u0438\u0435<\/a> <a href=\"http:\/\/kontromat.ru\/?page_id=5177\">\u0441\u0430\u0439\u0442\u044b<\/a><br \/>  3. <a href=\"https:\/\/habr.com\/post\/63982\/\">\u041f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a><\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \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\/post\/422009\/\"> https:\/\/habr.com\/post\/422009\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/422009\/\" class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f! \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0437 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b \u00ab\u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439\u00bb \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e \u0412\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438 \u043a\u0430\u043a \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0442\u0435\u043e\u0440\u0438\u0438 \u043f\u0440\u043e \u0442\u043e, \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438 \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0435\u0433\u043e \u043d\u0430 \u043c\u043d\u043e\u044e \u0432\u044b\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0438 \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u043c \u043d\u0430\u0431\u0440\u043e\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0430 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-_\/br\/t9\/-_brt9eary_qbrmnem54sxqslle.jpeg\" alt=\"image\">  <\/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-288844","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288844","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=288844"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288844\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}