QOJ.ac

QOJ

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

#22491. شراء العلف

Statistics

يذهب Farmer John للبلدة لجلب $K$ ($1 \le K \le 10,000$) أرطال علف. الميل مع $K$ يكلف $K*K$ سنتًا، و$D$ أميال $D*K*K$.

$N$ ($1 \le N \le 500$) متاجر $1..N$ على محور $X$ بطول $E$ ($1 \le E \le 500$) أميال. المتجر $i$ في $X_{i}$ ($0 < X_{i} < E$)، يبيع حتى $F_{i}$ ($1 \le F_{i} \le 10,000$) أرطال بـ$C_{i}$ ($1 \le C_{i} \le 10,000,000$) سنت للرطل. قد تتعدد المتاجر في النقطة.

من 0 باتجاه موجب فقط، يصل $E$ ومعه على الأقل $K$. يتوقف بأي متجر ويشتري أي كمية حتى حده.

أوجد أقل شراء ونقل لـ$K$ أرطال، وهو يعلم إمكان شراء الكفاية.

رطلان وثلاثة متاجر في 1,3,4 من $0..5$:

      0   1   2   3   4   5  X
      +---|---+---|---|---+
          1       1   1      الأرطال المتاحة
          1       2   2      السنتات للرطل

الأفضل رطل من الثاني والثالث، سنتان لكل رطل، شراء 4. 0–3 بلا حمولة مجاني؛ 3–4 ميل برطل يكلف $1*1*1 = 1$ سنت.

4–5 ميل برطلين يكلف $1*2*2 = 4$ سنتات.

الشراء $2+2$ والنقل $1+4$، المجموع $2 + 2 + 1 + 4 = 9$ سنتات.

الإدخال

  • السطر 1: الصحيحة $K$ و$E$ و$N$ بمسافات.
  • الأسطر $2..N+1$: السطر $i+1$ بالصحيحة $X_{i}$ و$F_{i}$ و$C_{i}$ بمسافات.

الإخراج

  • السطر 1: صحيح، أقل شراء ونقل.

أمثلة

الإدخال 1

2 5 3
3 1 2
4 1 2
1 1 1

الإخراج 1

9

مؤلف المسألة: Tom Conerly، 2009

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.