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.