{"id":4368,"date":"2018-12-24T20:11:29","date_gmt":"2018-12-24T17:11:29","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4368"},"modified":"2018-12-27T23:24:03","modified_gmt":"2018-12-27T20:24:03","slug":"e-olymp-5282-%d1%81%d0%b5%d0%b4%d0%bb%d0%be%d0%b2%d1%8b%d0%b5-%d1%82%d0%be%d1%87%d0%ba%d0%b8","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4368","title":{"rendered":"e-olymp 5282. \u0421\u0435\u0434\u043b\u043e\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u0417\u0430\u0434\u0430\u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 [latex]K[\/latex], \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f [latex]n[\/latex] \u0441\u0442\u0440\u043e\u043a \u0438 [latex]m[\/latex] \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0421\u0435\u0434\u043b\u043e\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c \u0432 \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u043e\u043c \u0432 \u0441\u0432\u043e\u0451\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435.<br \/>\n\u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0434\u043b\u043e\u0432\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<br \/>\n<img decoding=\"async\" data-attachment-id=\"22446\" data-permalink=\"http:\/\/cpp.mazurok.com\/e-olymp-5282\/saddle_point1\/#main\" data-orig-file=\"http:\/\/cpp.mazurok.com\/wp-content\/uploads\/2018\/02\/Saddle_point1.svg\" data-orig-size data-comments-opened=\"1\" data-image-meta=\"[]\" data-image-title=\"Saddle point\" data-image-description=\"&lt;p&gt;Saddle point&lt;\/p&gt;\n\" data-medium-file=\"http:\/\/cpp.mazurok.com\/wp-content\/uploads\/2018\/02\/Saddle_point1.svg\" data-large-file=\"http:\/\/cpp.mazurok.com\/wp-content\/uploads\/2018\/02\/Saddle_point1.svg\" src=\"http:\/\/cpp.mazurok.com\/wp-content\/uploads\/2018\/02\/Saddle_point1.svg\" alt=\"Saddle point\" class=\"alignright size-medium wp-image-22446 jetpack-lazy-image\" data-lazy-src=\"http:\/\/cpp.mazurok.com\/wp-content\/uploads\/2018\/02\/Saddle_point1.svg?is-pending-load=1\"><\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 [latex]n[\/latex] \u0438 [latex]m[\/latex]. [latex](1 \u2264 n, m \u2264 750)[\/latex]. \u0414\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 [latex]n[\/latex] \u0441\u0442\u0440\u043e\u043a \u043f\u043e [latex]m[\/latex] \u0447\u0438\u0441\u0435\u043b \u0432 \u043a\u0430\u0436\u0434\u043e\u0439. [latex]j[\/latex]-\u043e\u0435 \u0447\u0438\u0441\u043b\u043e [latex]i[\/latex]-\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0440\u0430\u0432\u043d\u043e [latex]k_{ij}[\/latex]. \u0412\u0441\u0435 [latex]k_{ij}[\/latex] \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043d\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0442 [latex]1000[\/latex].<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0434\u043b\u043e\u0432\u044b\u0445 \u0442\u043e\u0447\u0435\u043a.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table>\n<tbody>\n<tr>\n<th>#<\/th>\n<th>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<th>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>2 2<br \/>\n0 0<br \/>\n0 0<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>3 3<br \/>\n1 2 3<br \/>\n4 3 6<br \/>\n9 5 3<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>\n4 4<br \/>\n1 2 0 0<br \/>\n2 2 4 4<br \/>\n0 0 1 1<br \/>\n3 4 2 1<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td> 2 2<br \/>\n3 2<br \/>\n1 1<\/td>\n<td>1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<pre class=\"lang:java decode:true \">\/* package whatever; \/\/ don't place package name! *\/\r\n\r\nimport java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\n\r\n\/* Name of the class has to be \"Main\" only if the class is public. *\/\r\nclass Main\r\n{\r\n\tpublic static  int Unknown = 1001;\r\n\tpublic static void main (String[] args) throws java.lang.Exception\r\n\t{\r\n\t\tint n, m,uf = 0,maxi;\r\n\t\t\/\/input\r\n\t\tScanner in = new Scanner(System.in);\r\n\t\tn = in.nextInt();\r\n\t\tm = in.nextInt();\r\n\t\tint [][] x = new int[n][m]; \r\n    \tfor (int i = 0; i &lt; n; i++) \r\n        \tfor (int j = 0; j &lt; m; j++) \r\n            \tx[i][j] = in.nextInt();\r\n    \t\/\/workspace\r\n    \tint[] max = new int[m];\r\n    \tfor (int i = 0; i &lt; m; i++){\r\n    \t    max[i] = Unknown;   \r\n    \t}\r\n\t\tfor (int i = 0; i &lt; n; i++) {\r\n        \tint min = x[i][0];\r\n        \tfor (int j = 1; j &lt; m; j++) {\r\n            \tif ( min &gt; x[i][j] ) {\r\n                \tmin = x[i][j];\r\n            \t}\r\n        \t}\r\n        \tfor (int j = 0; j &lt; m; j++) {\r\n            \tif (x[i][j] == min) {\r\n                \tif (max[j] != Unknown){\r\n                    \tmaxi = max[j];  \r\n                \t}\r\n                \telse {\r\n                    \tmaxi = x[i][j];\r\n                    \tfor (int l = 0; l &lt; n; l++) {\r\n                    \t    if (maxi &lt; x[l][j]){\r\n                        \t    maxi = x[l][j];\r\n                        \t}\r\n                    \t}\r\n                    \tmax[j] = maxi;\r\n                \t}\r\n                \tif ( maxi == min) {\r\n                    \tuf++;\r\n                \t}\r\n            \t}\r\n    \t\t}\r\n    \t}\r\n    \t\/\/output\r\n\t\tSystem.out.print(uf);\r\n\t\t}\r\n}<\/pre>\n<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0434\u0432\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u0430. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u043d\u0430\u0439\u0434\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u043e\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u043e\u043c \u0432 \u0441\u0432\u043e\u0435\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 [latex]([\/latex] \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043b\u0435\u0436\u0430\u0442 \u0432\u0441\u0435 [latex]Unknown ([\/latex] \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u0440\u0430\u0432\u043d\u0430\u044f [latex]1001[\/latex][latex] ([\/latex] \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u0447\u0438\u0441\u043b\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0432\u0432\u043e\u0434\u0438\u043c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c [latex]1000 ) ) )[\/latex] \u043d\u0435 \u0440\u0430\u0432\u0435\u043d [latex]Unknown[\/latex], \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c, \u0438\u043d\u0430\u0447\u0435 \u043d\u0430\u0439\u0434\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0435\u0433\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0448\u043b\u0430 \u0440\u0435\u0447\u044c \u0440\u0430\u043d\u0435\u0435 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0443\u0436\u0435 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0438. \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0442\u043e \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0441\u0435\u0434\u043b\u043e\u0432\u0430\u044f \u0442\u043e\u0447\u043a\u0430!<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/5282\"> e-olymp.com.<\/a><\/p>\n<p>\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 <a href=\"https:\/\/ideone.com\/SXiRYM\">ideone.com.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0417\u0430\u0434\u0430\u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 [latex]K[\/latex], \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f [latex]n[\/latex] \u0441\u0442\u0440\u043e\u043a \u0438 [latex]m[\/latex] \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0421\u0435\u0434\u043b\u043e\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c \u0432 \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u043e\u043c \u0432 \u0441\u0432\u043e\u0451\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0434\u043b\u043e\u0432\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 [latex]n[\/latex] \u0438 [latex]m[\/latex]. [latex](1 \u2264 n, m \u2264 750)[\/latex]. \u0414\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 [latex]n[\/latex] \u0441\u0442\u0440\u043e\u043a \u043f\u043e &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4368\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":130,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[585,138,586],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4368"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/130"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4368"}],"version-history":[{"count":3,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4368\/revisions"}],"predecessor-version":[{"id":4371,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4368\/revisions\/4371"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}