QOJ.ac

QOJ

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

#21049. طابور الليمونادة

Statistics

في يوم صيفي حار، يقدم Farmer John الليمونادة لأبقاره الـ $N$! كلها، المرقمة $1 \dots N$، تحبها لكن بعضها أكثر من غيره. تقبل البقرة $i$ الانتظار خلف $w_i$ أبقار على الأكثر. الآن في الحقول، لكنها ستتدفق فور رنين الجرس نحو الكشك. تصل كلها قبل بدء التقديم ولا تصل اثنتان معًا. تنضم البقرة $i$ إذا وفقط إذا كان في الطابور حينها $w_i$ أبقار على الأكثر.

يريد FJ تحضير الليمونادة مسبقًا دون هدر. يتوقف عدد المنضمات على ترتيب الوصول. أوجد أقل عدد ممكن.

الإدخال

يحتوي السطر الأول على $N$، والثاني على $N$ عددًا صحيحًا $w_1, w_2, \dots, w_N$ تفصل بينها فراغات. يُضمن $1 \leq N \leq 10^5$ و$0 \leq w_i \leq 10^9$ لكل بقرة $i$.

الإخراج

اطبع أقل عدد من الأبقار المنضمة بين جميع ترتيبات الوصول الممكنة.

أمثلة

الإدخال 1

5
7 1 400 2 2

الإخراج 1

3

ملاحظة

هنا الحد الأدنى $3$. تصل أولًا البقرتان ذواتا $w=7$ و$w=400$ وتنتظران. تنصرف ذات $w=1$ لوجود $2$ قبلها في الطابور. ثم تصل ذواتا $w=2$، فتبقى واحدة وتنصرف الأخرى.

مؤلف المسألة: Dhruv Rohatgi

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.