ç´¯ç©max
å·¦å³ããã®ç´¯ç©åã»ç´¯ç© max ãåå¦çã§æ±ãã¦ããã®ã¯ãããããå ¸åï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æ´æ°ãããªãæ°å ãä¸ããããã次㮠åã®ã¯ã¨ãªã«çããã ãã¯ã¨ãªã åºé ãä¸ããããã®ã§ãæ°åãããã®åºéãé¤å¤ããé åã«ã¤ãã¦ãæ´æ°å¤ã®æâ¦
é¢ç½ãã£ããJOI ã§ããããããªåé¡ãé·æ¹å½¢ã 3 æ並ã¹ãã®ã¯å ¸åãããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã®ã°ãªããããã£ã¦ãåãã¹ ã«ã¯æ°å¤ ãæããã¦ããã ãã®ã°ãªããä¸ã§ ã®æ£æ¹å½¢ãéãªããªãããã« 3 æ並ã¹ãã¨ãããããã®æ£æ¹å½¢ã«è¦ããããã¹ã®â¦
åã®ãã®ãã åé¤ãããã®ãèããã®ã¯è²ã å®ç³ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æ´æ° ãä¸ããããã å ã«å¯¾ãã¦ã ãé¤å¤ãã åã®æ´æ°ã®æ大å¤ãæ±ããã å¶ç´ è§£æ³ (1)ï¼ã¢ãããã¯ã«èãã ã¾ãã¯ç´ æ´ãªè§£æ³ãèãã¦ã¿ãããã¨ãã° ã¨ãã ã£ãã¨â¦
ç´¯ç©åã®ç´¯ç© max åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æ°å ãä¸ãããã¾ãã ãã®æ°åã¯è² ã®è¦ç´ ãå«ãããããã¾ããã æ°ç´ç·ä¸ã®åº§æ¨ 0 ã«ç½®ããã¦ãããããããã以ä¸ã®åä½ãé ã«è¡ãã¾ãã æ£ã®åãã« é²ãã æ£ã®åãã« é²ã¿ãæ£ã®åãã« é²ãã æ£ã®åãã« â¦
Greedy ãèå¯ãã¦ãããã«å·¦å³ããç´¯ç©åãæ±ããï¼çµæ§é£ããï¼ åé¡ã¸ã®ãªã³ã¯ editorial é¡é¡ã¨ã drken1215.hatenablog.com åé¡æ¦è¦ é·ã ã®æ°å ã¨ãé·ã ã®æ°å ãä¸ãããã¾ããå ã«å¯¾ãã¦ã次ã®å¤ãæ±ããã æ°å ãã ãé¤å»ãã¦ã§ããé·ã ã®æ°â¦
è¿å¹´é常ã«ããè¦ã DP é«éåç³»åé¡ï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã® 3 ã¤ã®æ°å ãä¸ããããã ãã¾ãæ°å ãããã¤ãã®é£ç¶ããé¨ååã«åå²ãããã¨ãèããã åå² ã«å¯¾ãã¦ãã¹ã³ã¢ããååºéã«ã¤ãã¦ã®ä»¥ä¸ã®å¤ã®æå°å¤ã¨ãã¦å®ããã ãã®åºéâ¦
é£ããã£ã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ä½éã ã§ãããã㪠ä½ã®ã©ã¯ãããããã©ã¯ããä¸åã«ä¸¦ã¹ãæ¹æ³ã®ãã¡ã次ã®æ¡ä»¶ãæºãããã®ã«ã¤ãã¦ã左端ã®ã©ã¯ãã¨å³ç«¯ã®ã©ã¯ãã®è·é¢ã¨ãã¦èããããæå°å¤ãæ±ãããã¾ãããã®ããã«ã©ã¯ãã並ã¹ããã¨ãä¸å¯â¦
ãããæãåºãã drken1215.hatenablog.com åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã®ã°ãªãããä¸ããããããããã¹ã¯å£ ('#') ã«ãªã£ã¦ãã¦ããããã¹ã¯éè·¯ ('.') ã«ãªã£ã¦ãããéè·¯ãã¹ã åããã¨ãã¦ããã¹ã¦ã®ãéè·¯ãã¹ã®é¨åéåã ( éããã) ã«å¯¾ãã¦ã以â¦
ãããããããæã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ äºæ¬¡å å¹³é¢ä¸ã« åã®ç¹ () ã¨ã åã®ç¹å æº () ããããä»ã åã®ç¹ã«å¯¾ãã¦ä»¥ä¸ã®æä½ãè¡ã åã®ç¹ãä¸å¾ã«å³ã«åãã åã®ç¹ãä¸å¾ã«ä¸ã«åãã ãã®æä½ã«ãã£ã¦ããã¹ã¦ã®ç¹ã«ã¤ãã¦ãã©ã®ç¹å æºã®å³ä¸å´ã«â¦
æ¯è¼çç°¡åæ ã ã¨ã¯æã£ã¦ãããã©ãB ããã解ãããã®ã¯ã³ã£ããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åæµ·éé«æ ¡ã«ã¯ åã®ç§ç®ãããããããã 1, 2, 3 ã® 3 段éã§æ績ãã¤ããããã åçå¾ã®æ績ã¯é·ã ã®æååã§è¡¨ããã çå¾ ãçå¾ ã®ãä¸ä½äºæãã§ããã¨â¦
ã»ã°æ¨ã使ã£ã¦å·®åæ´æ°ãã¦ããç³»ã解ãããã©å®è£ ãè¦æãããã®ã§ãããããã®ãã¹ããã¨æ¸ããããã«ãªãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æ¦å¨ã¨ã åã®ç¾ãæã£ã¦ã ä½ã®æµã«ç«ã¡åããããããªã¯æ¦å¨ã®ä¸ãã 1 åãç¾ã®ä¸ãã 1 åãé¸ã¶ (åæç¶â¦
ãããå®ã¯ããããå ¸ååé¡ã ã£ããã¯ããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ä¸ã®ãã㪠ã®äºæ¬¡å ã°ãªãããä¸ããããã #..#.. .....# ....#. #.#... ãã®ã°ãªãã㧠'#' ã¯å£ã表ãã¦ããããã㧠'.' ãã¹ã 1 ã¤é¸ãã§ãããã«å æºãç½®ããããå æºãç §ããâ¦
ããããã®ãç´ æ©ãã¹ãã¬ã¹ãªãæ¸ããããã«ãªãã¨ããæããªæ°ããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æµ·ããé çªã«å»ºç© ããã£ã¦ãããããã®é«ã㯠ã§ããã æµ·ãè¦ãã建ç©ãä½åããããæ±ããããªãã çªç®ã®å»ºç©ããæµ·ãè¦ããã¨ã¯ ããåã® çªç®ã®å»ºç©ããâ¦
ã¾ããã¦ããæå¾ã®æå¾ãããè©°ãããã... (ã§ããã®æå¾ã®ã¨ããã®è©°ãã®å¤§å¤ããããã®é£æ度帯ã®ç¹å¾´ãªãã ãã) åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é ç¹ã®ããªã¼ãä¸ãããããæ ¹ãã¼ãã®çªå·ã 1 ã¨ãããåãã¼ã ã«ã¤ãã¦ã以ä¸ã®ã¯ã¨ãªã«çãã: åæç¶æ ãâ¦
åºéã«ã¤ãã¦ã©ãã®ããã®ããåé¡ã大æµã¯ DPï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æ´æ° ãããããããã®ãã¡ããã¤ãé¸ãã åè¨ãæ大åãããããã ãã ã®åºé [ ] ããã£ã¦ãé¸ãã æ°ã®ã©ã® 2 ã¤ãã¨ã£ã¦ãåä¸åºéä¸ã«ãªããªãããã«ããªããã°ãªããªãã â¦
ãã¼ã¼ã¼ã¼ã¼ãã©ããã¦ãã°ã«æ°ã¥ããªãã£ããããorz åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ x 軸ä¸ã«æ辺ãæã¤ãããªç´è§äºç辺ä¸è§å½¢ (ä¸é ç¹ã¯ã©ããæ ¼åç¹) ã N åä¸ãããããN åã®ç´è§äºç辺ä¸è§å½¢ã«ãã£ã¦è¢«è¦ãããæ ¼åç¹ã®ç·æ°ãæ±ããã å¶ç´ 1 <= N <= 10â¦