ããã«ã¡ã¯ãã»ãããã§ãã
æè¿ã競æããã°ã©ãã³ã°ãã¯ããã¾ããã
çµæ§ããã£ã¦ã¦ãã¨ããããå¹´å æ°´è²ç®æãã¦ãã¾ãã æ°´è²ã«ãªã£ãããã¤é¡ã§ã¤ããªããã°æ´æ°ãã¾ãð
ã¢ã«ã´ãªãºã ç³»ã®ãåå¼·ãå ¨ããã£ããã¨ãªãã£ãã®ã§ã ä»ã¾ã§ç¥ããªãã£ã or æèããªãã£ãã¢ã«ã´ãªãºã ã使ããããã«ãªã£ã¦ããã®ããã¨ã¦ã楽ããã®ã§ãã ç¡æã§éå ·ãè²°ããã¨ãã§ãããªãã¦ãã»ãã¨æé«ã§ãããã
éå ·ãæã£ã¦ããã¨ä½¿ããããªãã®ãæ§ã§ããå æ¥ããããªå ´é¢ã«ééãã¦å¬ããã£ãã®ã§æ¸ãã¦ããã¾ãã
æ¹æãã£ã·åé¡
åºå¼µã§æ¹æãéãç´åããµã¨æãã¾ããã
ã»ãããåã¯ãéæ²¢ã«è¡ããå符ã®æå®ç¯å²å ã®æ¹æã§ã®ä¹ãæãã§ã¯ãå¿ ãå½è©²å符ãéããªããã°ãªããªããå ¨ã¦ã®å符ãéãæ¹æã¯ã©ãã§ãããï¼
— ã»ããã (@hokekiyoo) May 29, 2019
âimosæ³ã£ã½ãï¼ï¼
ã¨ãªããªããåºå¼µãã¦ãã pic.twitter.com/yKV9gkHU5x
æ°å¹¹ç·ã¨ã使ãã¨ãã«ã大éã®ãã£ã·ãæãåºããã¾ãããï¼ãã®æã®æ¹æãã¨ã«ä½æã®ãã£ã·ãå ¥ããã°è¯ããã ï¼ï¼ã¨ããåé¡ã§ãã
ã¡ãªã¿ã«ãæ±äº¬ã®æ¹æã¯è³¢ãã¦é©å½ã«å ¨é¨å ¥ããããããªã«ãã¦ããããã§ãããå®åã¯ããã¯ããã¾ãããåºéå¤ã®ãã£ã·ãå ¥ããã¨æ¹æãéãã¦ããã¾ããããã¼ãã¢ã¼ãã§ãã
ãããæ³
ãã®ãããªå§ç¹ã¨ç«¯ç¹ã決ã¾ã£ã¦ãã¦ãæ°ãæ°ããåé¡ã¯ããããæ³ã¨ããã®ãå¹çãããã常å¥æ段ã¨ãªã£ã¦ãã¾ãã
åºå ¥ãå£ã ãã«ã¦ã³ãããã°ãä¸èº«ã¯å¾å¦çã§ãããã¨ããçºæ³ã§ãã å³ã«ããã¨ãããªæãã
ãã®ã¾ãã¾ãã®æ¹æãã£ã·åé¡ã«ä½¿ãããã§ãï¼ååºéã§
ã¨ãã¦ããã¦ãç´¯ç©å(ã¯ãããã足ãä¸ãã¦ãã)ãåãã¨ãã®ã¨ãã«å¿ è¦ãªãã±ããæ°ãåºã¾ã
解ãã
å®è£ ã¯ã¨ã¦ãç°¡åã§ããpythonã§å®è£ ãã¦ã¿ã¾ããã
ç´¯ç©åã®è¨ç®ã«ã¯itertools
ã«å
¥ã£ã¦ããaccumlate
ã便å©ã§ããä¸ç¬ã§çµããã¾ãã
from itertools import accumulate As = ["å®å","åå¤å±","ç±³å","éæ²¢"] tickets = [(0,3),(1,2),(2,3)] imos = [0]*5 for s,g in tickets: imos[s] += 1 imos[g+1] -= 1 cum = list(accumulate(imos)) for num, A in zip(cum,As): print("{}\t{}".format(A,num))
ãããåºåããã¨...
å®å 1 åå¤å± 2 ç±³å 3 éæ²¢ 2
ãã¡ãã¨ãã®å ´æå ´æã§å¿ è¦ãªãã£ã·ææ°ãåºã¦ãã¾ãï¼ãããæ³ãã³ã¶ã¤ï¼
ã¾ã¨ã
ä»åã®ã¯çµæ§ç°¡åãªåé¡ã§ãããããããã£ã¦ãå¦ãã ãã¨ãæ®æ®µã®çæ´»ã«æ´»ãããããã¨ãåå¼·ã楽ãããªã£ã¦ãã¾ããï¼
ã¡ãªã¿ã«ãèããããã¨âã®äººã¿ããã«æ¥å¸¸çæ´»ã«æ¯éãããããã¨ãããã®ã§æ³¨æãå¿ è¦ã§ããã
æã絶対å¤ã®æå°å¤åããããªåé¡ã解ããå¾ã®åºå¤ä¸ãã³ã³ããã§283åã®ãè²·ãç©ã«å¯¾ãã3åã®ãé£ããæå°ã ããããªã©ã¨æã280åãããéãåºãããåºå¡ã«ããã£â¦ãã¿ãããªé¡ãããã®ã§ãèªåãä»é±ãã£ã±ãæä¼ã¨ã£ã¦ããããï¼
— ã»ããã (@hokekiyoo) May 26, 2019
ä»å¾ãã»ã©ã»ã©ã«ç²¾é²ãã¦ããã¾ãï¼ã§ã¯ã§ã¯ã£