QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#22525. הוצאה חודשית

الإحصائيات

Farmer John הוא אשף חשבונאות מדהים והבין שעלול להיגמר לו הכסף להפעלת החווה. הוא חישב ורשם בדיוק את ההוצאה ($1 \le money_{i} \le 10,000$) בכל אחד מ־$N$ הימים הבאים ($1 \le N \le 100,000$).

FJ רוצה תקציב לרצף של בדיוק $M$ תקופות כספיות ($1 \le M \le N$), בשם ״fajomonths״. כל תקופה כוללת יום אחד או יותר רצופים, וכל יום שייך בדיוק לתקופה אחת.

הוא רוצה לסדר את התקופות כדי למזער את הוצאת התקופה היקרה ביותר וכך לקבוע מגבלה חודשית.

קלט

שורה 1: שני שלמים מופרדים ברווח, $N$ ו־$M$. שורות $2\ldots N+1$: שורה $i+1$ מכילה את מספר הדולרים ש־Farmer John מוציא ביום ה־$i$.

פלט

שורה 1: המגבלה החודשית הקטנה ביותר ש־Farmer John יכול להסתדר איתה.

דוגמאות

קלט 1

7 5
100
400
300
100
500
101
400

פלט 1

500

הערה

אם היומיים הראשונים חודש, השלישי והרביעי חודש, וכל אחד משלושת האחרונים חודש נפרד, הוא מוציא לכל היותר 500 דולר בחודש. כל חלוקה אחרת נותנת מגבלה חודשית מזערית גדולה יותר.

מקור הבעיה: USACO, מרץ 2007.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.