SlideShare a Scribd company logo
第2回	
 早稲田大学プログラミングコンテスト	
  




  keyword:	
  シミュレーション、貪欲法	
  
5	
 
                                        4	
                         3	
 
           2	
           3	
 
1
                                1   1   1
                                                             4	
           4	
 
    2	
           2	
                          3	
 
                                1   1   1




          立方体のオブジェが	
  
    たくさん(各サイズにつき<=109)与えられます。
5	
 
                                        4	
                                3	
 
           2	
           3	
 
1
                                1   1   1
                                                                    4	
           4	
 
    2	
           2	
                          3	
 
                                1   1   1



はみ出ないように	
  
  詰める!	
                                              5	
                  5	
 
    ⇒
5	
 
                                       4	
                                3	
 
           2	
          3	
 
1
                               1   1   1
                                                                   4	
           4	
 
    2	
           2	
  5	
 
                               1   1   1はいくつ必要?	
 
                                              3	
 




はみ出ないように	
  
  詰める!	
                                             5	
                  5	
 
    ⇒
提供	
 
                            この問題は	
 
                                       5	
 
                            4	
               3	
 
      2	
    3	
 
株式会社	
 リクルートコミュニケーションズ	
  
 1
             1  1 1

   2	
 
        http://www.rco.recruit.co.jp/	
  4	
 
        2	
          3	
 
                            4	
 
                    1   1   1


                    さんの提供でお送りしました	
 
  はみ出ないように	
  
    詰める!	
                5	
       5	
 
      ⇒	
    [!]	
  問題の原案をいただきました。ありがとうございました。
¡  落ち着いて考えれば難しくないはずです	
  
	
  
¡  基本戦略	
  :	
  大きい方から詰めていけばOK	
  


¡  以下の情報を変数で持っておく	
  
       §  いくつコンテナを使ったか	
  :	
  answer	
  
       §  それぞれのサイズのオブジェがいくつあるか	
  :	
  
        objects[size	
  :	
  1〜5]	
  
¡  これは、1つにつき必ず1コンテナ必要	
  
       §  他に何も詰められない	
  
	
  
       §  answer	
  +=	
  objects[5]	
  
       §  objects[5]	
  =	
  0	
  
¡  これも、1つにつき必ず1コンテナ必要	
  
       §  他に、あと1x1x1が	
  53-­‐43	
  =	
  61	
  個詰められる	
  
	
  
       §  answer	
  +=	
  objects[4]	
  
       §  objects[1]	
  -­‐=	
  min(objects[1],	
  61	
  *	
  objects[4])	
  
       §  objects[4]	
  =	
  0	
  
¡  これも、1つにつき必ず1コンテナ必要	
  
 §  他に、あと1x1x1が	
  53-­‐33	
  =	
  98	
  個詰められる	
  


¡  でも、可能ならば	
  2x2x2	
  を詰めたい。	
  
 §  3x3x3を入れたあとで、2x2x2はいくつ入る?	
  
このような状態であといくつ入るか?	
  
              	
  
              立体のままだとわかりにくいので・・・	
 




       5	
 
3
それぞれの高さの	
  
              断面図の状態を	
 
       5	
 
3
-----   -----
                             -----   -----
                             -----   ***--
                             -----   ***--
                             -----   ***--

                             -----   -----
              それぞれの高さの	
  
                             -----   -----
              断面図の状態を	
      -----   ***--
       5	
                   -----   ***--
                             -----   ***--
3	
 
                             -----
                             -----
                             ***--
                             ***--
                             ***--
                             	
 


                               テキストに表す
-----   -----   -----
-----   -----   -----
-----   ***--   ***--
-----   ***--   ***--     これに、	
 
-----   ***--   ***--
                	
         XX
                           XX	
 
-----   -----
-----   -----              XX
-----   ***--              XX	
 
-----   ***--           が幾つ入るかを考える	
 
-----   ***--
XX---   -----   -----
XX---
-----
-----
        -----
        ***--
        ***--
                -----
                ***--
                ***--
                        1	
 
-----   ***--   ***--
                	
 
XX---   -----
XX---   -----
-----   ***--
-----   ***--
-----   ***--
XXXX-   -----   -----
XXXX-
-----
-----
        -----
        ***--
        ***--
                -----
                ***--
                ***--
                        2	
 
-----   ***--   ***--
                	
 
XXXX-   -----
XXXX-   -----
-----   ***--
-----   ***--
-----   ***--
XXXX-   -----   -----
XXXX-
XX---
XX---
        -----
        ***--
        ***--
                -----
                ***--
                ***--
                        3	
 
-----   ***--   ***--
                	
 
XXXX-   -----
XXXX-   -----
XX---   ***--
XX---   ***--
-----   ***--
XXXX-   -----   -----
XXXX-
XXXX-
XXXX-
        -----
        ***--
        ***--
                -----
                ***--
                ***--
                        4	
 
-----   ***--   ***--
                	
 
XXXX-   -----
XXXX-   -----
XXXX-   ***--
XXXX-   ***--
-----   ***--
XXXX-   XX---   -----
XXXX-
XXXX-
XXXX-
        XX---
        ***--
        ***--
                -----
                ***--
                ***--
                        5	
 
-----   ***--   ***--
                	
 
XXXX-   XX---
XXXX-   XX---
XXXX-   ***--
XXXX-   ***--
-----   ***--
XXXX-   XXXX-   -----
XXXX-
XXXX-
XXXX-
        XXXX-
        ***--
        ***--
                -----
                ***--
                ***--
                        6	
 
-----   ***--   ***--
                	
 
XXXX-   XXXX-
XXXX-   XXXX-
XXXX-   ***--
XXXX-   ***--
-----   ***--
XXXX-   XXXX-   -----
XXXX-
XXXX-
XXXX-
        XXXX-
        ***--
        ***--
                -----
                ***--
                ***XX
                        7	
 
-----   ***--   ***XX
                	
 
XXXX-   XXXX-
XXXX-   XXXX-
XXXX-   ***--
XXXX-   ***XX
-----   ***XX
XXXX-   XXXX-   -----
XXXX-   XXXX-   -----
XXXX-   ***--   ***--
XXXX-   ***--   ***XX
-----   ***--   ***XX
                	
 
XXXX-   XXXX-
XXXX-
XXXX-
        XXXX-
        ***--           これ以上	
  
XXXX-
-----
        ***XX
        ***XX           入らない!
¡  どのように詰めても、8個以上入らないこ
 とが分かります	
  
 §  なので、3を1つにつき2を7個	
  
 §  その隙間	
  :	
  (53-­‐33-­‐23*7	
  =	
  42)	
  に1を	
  
 §  もちろん、2が余ったらその分を1で詰める	
  


¡  [!]	
  要注意ポイント	
  :	
  コーナーケース	
  
¡  以上をプログラムにまとめると	
  


 §  answer	
  +=	
  objects[3]	
  
 §  useTwo	
  =	
  min(objects[2],	
  objects[3]	
  *	
  7)	
  
 §  objects[2]	
  -­‐=	
  useTwo	
  
 §  objects[1]	
  -­‐=	
  min(objects[1],	
  	
  
      	
  (125	
  -­‐	
  27)	
  *	
  objects[3]	
  –	
  useTwo	
  *	
  8)	
  
 §  objects[3]	
  =	
  0	
  
¡  これは、コンテナに8つ詰められる	
  
 §  余ったら1x1x1を詰める	
  


 §  containerForTwo	
  =	
  (objects[2]	
  +	
  7)	
  /	
  8	
  
 §  answer	
  +=	
  containerForTwo	
  
 §  objects[1]	
  -­‐=	
  min(objects[1],	
  	
  
      	
  125	
  *	
  containerForTwo	
  –	
  objects[2]	
  *	
  8)	
  
 §  objects[2]	
  =	
  0	
  
¡  それでも1x1x1が余ったら	
  
 §  1コンテナに付き125個詰める	
  


 §  answer	
  +=	
  (objects[1]	
  +	
  124)	
  /	
  125	
  
 §  objects[1]	
  =	
  0	
  


 §  answer	
  を出力	
  
¡  オーバーフロー	
  
 §  入力を最初からlongで受け取り、全部longで計
   算するとよい	
  
¡  3x3x3を詰める処理	
  
 §  2x2x2は7個入れてますか	
  
 §  2x2x2を途中で使い切った時、(入るはずだっ
   た2x2x2の所に)1x1x1を全て詰めていますか	
  
¡  大きいサイズを詰める処理	
  
 §  1x1x1の変数がマイナスになってませんか	
  
¡  0	
  70	
  10	
  0	
  0	
  -­‐>	
  10	
  
¡  0	
  71	
  10	
  0	
  0	
  -­‐>	
  11	
  
¡  244	
  0	
  0	
  4	
  0	
  -­‐>	
  4	
  
¡  245	
  0	
  0	
  4	
  0	
  -­‐>	
  5	
  
¡  420	
  70	
  10	
  0	
  0	
  -­‐>	
  10	
  
¡  421	
  70	
  10	
  0	
  0	
  -­‐>	
  11	
  
¡  92	
  13	
  2	
  0	
  0	
  -­‐>	
  2	
  
¡  93	
  13	
  2	
  0	
  0	
  -­‐>	
  3	
  
¡  First	
  AC	
  :	
  uwi	
  (20:21)	
  

¡  正解数	
  :	
  89	
  
   §  通した人(89/205)	
  :	
  43%	
  
   §  ACだった解答(89/571)	
  :	
  16%	
  

More Related Content

Recently uploaded

論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
atsushi061452
 
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
Sony - Neural Network Libraries
 
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
iPride Co., Ltd.
 
FIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdfFIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdfFIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance
 
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアルLoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
CRI Japan, Inc.
 
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
atsushi061452
 
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
harmonylab
 
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdfFIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance
 
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
NTT DATA Technology & Innovation
 
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
yassun7010
 
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
Fukuoka Institute of Technology
 
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdfFIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance
 
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
Matsushita Laboratory
 
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdfFIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance
 

Recently uploaded (15)

論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
 
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
 
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
 
FIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdfFIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdf
 
FIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdfFIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdf
 
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアルLoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
 
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
 
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
 
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdfFIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
 
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
 
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
 
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
 
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdfFIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
 
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
 
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdfFIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

WUPC2nd D問題

  • 1. 第2回 早稲田大学プログラミングコンテスト   keyword:  シミュレーション、貪欲法  
  • 2. 5 4 3 2 3 1 1 1 1 4 4 2 2 3 1 1 1 立方体のオブジェが   たくさん(各サイズにつき<=109)与えられます。
  • 3. 5 4 3 2 3 1 1 1 1 4 4 2 2 3 1 1 1 はみ出ないように   詰める!   5 5 ⇒
  • 4. 5 4 3 2 3 1 1 1 1 4 4 2 2 5 1 1 1はいくつ必要? 3 はみ出ないように   詰める!   5 5 ⇒
  • 5. 提供 この問題は 5 4 3 2 3 株式会社 リクルートコミュニケーションズ   1 1 1 1 2 http://www.rco.recruit.co.jp/ 4 2 3 4 1 1 1 さんの提供でお送りしました はみ出ないように   詰める!   5 5 ⇒ [!]  問題の原案をいただきました。ありがとうございました。
  • 6. ¡  落ち着いて考えれば難しくないはずです     ¡  基本戦略  :  大きい方から詰めていけばOK   ¡  以下の情報を変数で持っておく   §  いくつコンテナを使ったか  :  answer   §  それぞれのサイズのオブジェがいくつあるか  :   objects[size  :  1〜5]  
  • 7. ¡  これは、1つにつき必ず1コンテナ必要   §  他に何も詰められない     §  answer  +=  objects[5]   §  objects[5]  =  0  
  • 8. ¡  これも、1つにつき必ず1コンテナ必要   §  他に、あと1x1x1が  53-­‐43  =  61  個詰められる     §  answer  +=  objects[4]   §  objects[1]  -­‐=  min(objects[1],  61  *  objects[4])   §  objects[4]  =  0  
  • 9. ¡  これも、1つにつき必ず1コンテナ必要   §  他に、あと1x1x1が  53-­‐33  =  98  個詰められる   ¡  でも、可能ならば  2x2x2  を詰めたい。   §  3x3x3を入れたあとで、2x2x2はいくつ入る?  
  • 10. このような状態であといくつ入るか?     立体のままだとわかりにくいので・・・ 5 3
  • 11. それぞれの高さの   断面図の状態を 5 3
  • 12. ----- ----- ----- ----- ----- ***-- ----- ***-- ----- ***-- ----- ----- それぞれの高さの   ----- ----- 断面図の状態を ----- ***-- 5 ----- ***-- ----- ***-- 3 ----- ----- ***-- ***-- ***-- テキストに表す
  • 13. ----- ----- ----- ----- ----- ----- ----- ***-- ***-- ----- ***-- ***-- これに、 ----- ***-- ***-- XX XX ----- ----- ----- ----- XX ----- ***-- XX ----- ***-- が幾つ入るかを考える ----- ***--
  • 14. XX--- ----- ----- XX--- ----- ----- ----- ***-- ***-- ----- ***-- ***-- 1 ----- ***-- ***-- XX--- ----- XX--- ----- ----- ***-- ----- ***-- ----- ***--
  • 15. XXXX- ----- ----- XXXX- ----- ----- ----- ***-- ***-- ----- ***-- ***-- 2 ----- ***-- ***-- XXXX- ----- XXXX- ----- ----- ***-- ----- ***-- ----- ***--
  • 16. XXXX- ----- ----- XXXX- XX--- XX--- ----- ***-- ***-- ----- ***-- ***-- 3 ----- ***-- ***-- XXXX- ----- XXXX- ----- XX--- ***-- XX--- ***-- ----- ***--
  • 17. XXXX- ----- ----- XXXX- XXXX- XXXX- ----- ***-- ***-- ----- ***-- ***-- 4 ----- ***-- ***-- XXXX- ----- XXXX- ----- XXXX- ***-- XXXX- ***-- ----- ***--
  • 18. XXXX- XX--- ----- XXXX- XXXX- XXXX- XX--- ***-- ***-- ----- ***-- ***-- 5 ----- ***-- ***-- XXXX- XX--- XXXX- XX--- XXXX- ***-- XXXX- ***-- ----- ***--
  • 19. XXXX- XXXX- ----- XXXX- XXXX- XXXX- XXXX- ***-- ***-- ----- ***-- ***-- 6 ----- ***-- ***-- XXXX- XXXX- XXXX- XXXX- XXXX- ***-- XXXX- ***-- ----- ***--
  • 20. XXXX- XXXX- ----- XXXX- XXXX- XXXX- XXXX- ***-- ***-- ----- ***-- ***XX 7 ----- ***-- ***XX XXXX- XXXX- XXXX- XXXX- XXXX- ***-- XXXX- ***XX ----- ***XX
  • 21. XXXX- XXXX- ----- XXXX- XXXX- ----- XXXX- ***-- ***-- XXXX- ***-- ***XX ----- ***-- ***XX XXXX- XXXX- XXXX- XXXX- XXXX- ***-- これ以上   XXXX- ----- ***XX ***XX 入らない!
  • 22. ¡  どのように詰めても、8個以上入らないこ とが分かります   §  なので、3を1つにつき2を7個   §  その隙間  :  (53-­‐33-­‐23*7  =  42)  に1を   §  もちろん、2が余ったらその分を1で詰める   ¡  [!]  要注意ポイント  :  コーナーケース  
  • 23. ¡  以上をプログラムにまとめると   §  answer  +=  objects[3]   §  useTwo  =  min(objects[2],  objects[3]  *  7)   §  objects[2]  -­‐=  useTwo   §  objects[1]  -­‐=  min(objects[1],      (125  -­‐  27)  *  objects[3]  –  useTwo  *  8)   §  objects[3]  =  0  
  • 24. ¡  これは、コンテナに8つ詰められる   §  余ったら1x1x1を詰める   §  containerForTwo  =  (objects[2]  +  7)  /  8   §  answer  +=  containerForTwo   §  objects[1]  -­‐=  min(objects[1],      125  *  containerForTwo  –  objects[2]  *  8)   §  objects[2]  =  0  
  • 25. ¡  それでも1x1x1が余ったら   §  1コンテナに付き125個詰める   §  answer  +=  (objects[1]  +  124)  /  125   §  objects[1]  =  0   §  answer  を出力  
  • 26. ¡  オーバーフロー   §  入力を最初からlongで受け取り、全部longで計 算するとよい   ¡  3x3x3を詰める処理   §  2x2x2は7個入れてますか   §  2x2x2を途中で使い切った時、(入るはずだっ た2x2x2の所に)1x1x1を全て詰めていますか   ¡  大きいサイズを詰める処理   §  1x1x1の変数がマイナスになってませんか  
  • 27. ¡  0  70  10  0  0  -­‐>  10   ¡  0  71  10  0  0  -­‐>  11   ¡  244  0  0  4  0  -­‐>  4   ¡  245  0  0  4  0  -­‐>  5   ¡  420  70  10  0  0  -­‐>  10   ¡  421  70  10  0  0  -­‐>  11   ¡  92  13  2  0  0  -­‐>  2   ¡  93  13  2  0  0  -­‐>  3  
  • 28. ¡  First  AC  :  uwi  (20:21)   ¡  正解数  :  89   §  通した人(89/205)  :  43%   §  ACだった解答(89/571)  :  16%