QOJ.ac

QOJ

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

#22579. حلوى للأبقار

Statistics

اشترى FJ عدد $N$ $(1 \le N \le 2000)$ من الحلوى اللذيذة للأبقار التي تكسب المال بإنتاج حليب كثير. يبيع واحدة يوميًا ويزيد عائد الفترة لأقصاه.

لها مزايا:

  • مرقمة $1..N$ مرتبة في صف واحد بصندوق طويل مفتوح الطرفين. كل يوم يأخذ واحدة من أي طرف.
  • مثل النبيذ الجيد والجبن اللذيذ، تتحسن وتتغلى مع العمر.
  • متفاوتة، بعضها أفضل وذو قيمة أصلية أعلى. الحلوى $i$ قيمتها $v(i)$ ($1 \le v(i) \le 1000$).
  • تدفع الأبقار أكثر للأقدم: بعمر $a$ تدفع $v(i)*a$.

مع قيم $v(i)$ مرتبة بفهرس $i$ بالصندوق، ما أقصى عائد بترتيب بيع أمثل؟

الأولى تباع يوم 1 بعمر $a=1$، وكل يوم تال يزيد العمر 1.

الإدخال

  • السطر 1: صحيح $N$.
  • الأسطر $2..N+1$: السطر $i+1$ قيمة $v(i)$.

الإخراج

  • السطر 1: أقصى عائد للبيع.

أمثلة

الإدخال 1

5
1
3
1
5
2

الإخراج 1

43

ملاحظة

يبيع القيم $1, 3, 1, 5, 2$ بترتيب الفهارس $1, 5, 2, 3, 4$، فيكسب $1*1 + 2*2 + 3*3 + 4*1 + 5*5 = 43$.

المؤلف: Marco Gallotta (2005).

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.