挑戰題
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
挑戰題1
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
風起時,書頁翻飛如陣陣嘆息,浩然圖書館內,歲月靜靜堆疊成知識的長河。
自1958年,那些沉默的書本,等待著,誰能為它們點燃新生的光。
向荷與昱君,肩負著求知的信念,踏入這座書海殿堂,望著滿架書卷,立下誓言:
「就算披星戴月,就算蠟燭成灰,我們也要將這裡的每一本書,悉數讀完。」
圖書館中共有 本書,
而每本書蘊含不同深度的智慧,讀完所需時間分別為
館藏深處,流傳著一條古老的守則——
「每本書,只認一位讀者的眼睛,從開卷到終章,始終如一。
若有人中途接手,文字便會如煙消逝,知識將化為空白。」
沒人知道這規則從何而來,
有人說,是為了尊重書本的靈魂;
也有人說,是學者們對專注與恆心的最後考驗。
因此,她們只能分工而行,
一人一書,不可同時閱讀同本書,也不可交替。
她們知曉,這不僅是閱讀,
而是一場靜默的修行,一段孤獨卻無悔的旅程。
那麼,若兩人攜手分擔,遵循這既定的規則,
完成這場知識長征,所需的最短時間,究竟是多少?
輸入格式
第一行輸入有一個整數 :書籍的數量。
第二行有 個整數 :閱讀每本書所需的時間。
值域:
輸出格式
:最短總時間。
範例說明
輸入:
輸出:
閱讀順序分配方式(不一定只有一種分法):
在向荷讀完前兩本之後須等待昱君讀完第一本(耗時8)才能換她開始讀,因此總時間為16。
更多例子請參考測試資料。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
提示
不要想太複雜
Estimate codeforces rating : 1000
測試資料
1
輸入:
輸出:
17
2
輸入:
輸出:
61
3
輸入:
輸出:
22430
4
輸入:
輸出:
4953057
6
輸入:
輸出:
9235765
7
答案程式碼(寫完再看)
Problem Source
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
挑戰題2
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
在浩然圖書館最隱密的閣樓上,存放了一排神奇的古籍。經過研究,向荷與昱君發現這些書籍是擁有靈性的知識載體,每本書上都刻著一個數字代表其靈氣強度。而閣樓有個古老的守則
「在一次的閱讀中,這些古籍必須保持原有的排列順序,卻可以分配給不同讀者。每位讀者閱讀書籍時必須符合其心性——或漸進提升,或深入淺出。若違背規則,文字便會如煙消逝,知識將化為空白。」
向荷和昱君性格迥異。昱君性如清泉,思維漸進,喜歡循序漸進地吸收知識,適合靈氣由小到大的閱讀書籍;向荷則如山峰巍峨,思想跳脫,善於從複雜到簡單地歸納總結,更適合靈氣由強到弱的閱讀書籍。
然而在每次的閱讀向荷與昱君都會消耗大量心神,因此需要來罐 redbull 才能恢復體力。她們的 redbull 有限,因此必須設法用最少的次數共同讀完所有書籍,將寶貴的 redbull 用在刀口上。
任務描述
你被向荷與昱君委託協助完成這項任務:
你要將這些古籍 分配整理成最少數量的閱讀序列,使得:
- 適合向荷的閱讀序列靈氣值逐漸增大(符合她漸進的性格)
- 適合昱君的閱讀序列靈氣值逐漸減小(符合她歸納的思維)
- 每本書只能分配給一位讀者
- 書籍必須保持原有的擺放順序
- 閱讀序列的總數必須最少(以節省寶貴的 redbull)
輸入格式
第一行輸入有一個整數 :書籍的數量。
第二行有 個整數 :表示每本書的靈氣強度值,皆相異
值域:
輸出格式
輸出有一個整數 :最少要幾瓶 redbull。
範例說明
輸入:
輸出:
將 分成三個閱讀序列(不一定只有一種分法):
- 第一個序列包含 (靈氣值遞增,適合向荷)
- 第二個序列包含 (靈氣值遞減,適合昱君)
- 第三個序列包含 (靈氣值遞增,適合向荷)
這樣向荷與昱君只需 3 瓶 redbull,便能完成所有古籍的閱讀。
更多例子請參考測試資料。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
提示(先想一下別直接看)
題目白話文 : 給定一個整數數列,你需要將它拆成若干個子序列,使得每個子序列要麼嚴格遞增,要麼嚴格遞減,且總數最少。(NP-Hard 問題)
真的寫出來了記得告訴我,請你喝飲料
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Estimate codeforces rating : 1400
策略(再想一下別直接看)
DFS+剪枝
測試資料
1
輸入:
輸出:
1
2
輸入:
輸出:
1
3
輸入:
輸出:
2
4
輸入:
輸出:
2
5
輸入:
輸出:
3
6
輸入:
輸出:
2
7
輸入:
輸出:
4
8
輸入:
輸出:
5
9
你很厲害你很厲害你很厲害你很厲害你很厲害你很厲害你很厲害
答案程式碼(寫完再看)
這是較好理解的寫法,還有優化空間勿噴(NP-Hard 問題)
沒了
沒人發現挑戰題1測試資料5不見了嗎
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →