QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 256 MB Toplam puan: 100

#22376. البقرة البارومترية

İstatistikler

بعد قراءة مقال عن زيادة إنتاج الحليب، تدرس Bessie الضغط الجوي لكسب رضا Farmer John.

تأخذ $N$ قياسات ($(1 \le N \le 100)$)، تسمى $M_{1}$ إلى $M_{N}$ ($(1 \le M_{i} \le 1,000,000)$)، مرقمة بترتيب ملاحظتها.

لوصف ضغط اليوم تبحث عن مجموعة جزئية تمثل الكل بدقة وتحد الخطأ التالي: $K$ فهارس ($(1 \le K \le N)$) $s_{j}$ حيث $1 \le s_1 < s_2 < \cdots < s_K \le N$.

كل قياس قبل أول مختار، أو بين مختارين متتاليين، أو بعد آخر مختار يولد خطأ. خطأ مجموعة $s_{j}$ الإجمالي هو مجموع الأخطاء الفردية.

للقياسات التي فهرسها $i$ ليس ضمن $s_{j}$:

  • إذا $i$ أصغر من $s_1$، فالخطأ:

$$ 2 * | M_i - M_{s_1} | $$

  • إذا $i$ بين $s_j$ و$s_{j+1}$، فالخطأ:

$$ | 2 * M_i - \operatorname{Sum}(s_j, s_{j+1}) | $$

حيث $\operatorname{Sum}(x, y) = M_x + M_y$؛

  • إذا $i$ أكبر من $s_K$، فالخطأ:

$$ 2 * | M_i - M_{s_K} | $$

لأقصى خطأ $E$ ($(1 \le E \le 1,000,000)$)، أوجد أصغر حجم مجموعة جزئية بخطأ لا يتجاوز $E$.

الإدخال

  • السطر $1$: الصحيحان $N$ و$E$ مفصولان بمسافة.

  • الأسطر $2,\ldots,N+1$: السطر $i+1$ يحتوي الصحيح $M_{i}$.

الإخراج

  • السطر $1$: صحيحان مفصولان بمسافة، أصغر حجم بخطأ لا يتجاوز $E$ وأقل خطأ ممكن لذلك الحجم.

أمثلة

الإدخال 1

4 20
10
3
20
40

الإخراج 1

2 17

ملاحظة

القياسات $4$، حد الخطأ $20$، والقيم بالترتيب $10$ و$3$ و$20$ و$40$.

اختيار القياسين $2$ و$4$ أفضل، بخطأ $17$. الأول خطؤه $2\times |10-3| = 14$ والثالث $|2\times 20 - (3+40)| = 3$.

مؤلف المسألة: Jeffrey Wang، 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.