QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21377. חליבה מיטבית

Statistics

Farmer John רכש רפת חדשה עם $N$ מכונות חליבה ($1 \le N \le 40,000$), ממוספרות $1..N$ בשורה.

מכונה $i$ חולבת $M(i)$ יחידות ביום ($1 \le M(i) \le 100{,}000$). קרובות מדי: ביום שמשתמשים ב-$i$ אי אפשר להשתמש בשתי שכנותיה (בקצה רק אחת). בכל יום מותר לבחור תת-קבוצה אחרת.

הוא רוצה סך מרבי ב-$D$ ימים ($1 \le D \le 50,000$). בתחילת כל יום יש זמן לתחזק מכונה נבחרת $i$ ולשנות את התפוקה היומית $M(i)$ מאותו יום ואילך. לפי השינויים מצאו סך מרבי ב-$D$ ימים (ייתכן שלא ייכנס בשלם של 32 סיביות).

קלט

  • שורה 1: $N$ ו-$D$.
  • שורות $2..1+N$: שורה $i+1$ מכילה $M(i)$ התחלתי.
  • שורות $2+N..1+N+D$: שורה $1+N+d$ מכילה שלמים $i$, $m$, לשנות $M(i)$ ל-$m$ בתחילת יום $d$.

פלט

  • שורה 1: סך מרבי של FJ ב-$D$ ימים.

דוגמאות

קלט 1

5 3
1
2
3
4
5
5 2
2 7
1 10

פלט 1

32

הערה

5 מכונות עם תפוקות התחלתיות 1,2,3,4,5. ביום 1 מכונה 5 משתנה ל-2 יחידות וכן הלאה.

יום 1: מיטבי $2+4 = 6$ (גם $1+3+2$). יום 2: $7+4 = 11$. יום 3: $10+3+2=15$.

מחבר הבעיה: Brian Dean

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.