QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 256 MB Points totaux : 100

#22638. رقص القاعة للأبقار

Statistiques

الأبقار سيئة جدًا في الرقص. لكن Farmer John لاحظ أن الرشيقة تنتج حليبًا أكثر، فسجل القطيع كله في صف رقص القاعة. في الحصة الأولى، يجب إقران $N$ ذكرًا، أي ثورًا ($1\le N\le1{,}000$)، مع $N$ أنثى. يكون الزوج جيدًا عندما يكون الطولان متقاربين أي الفرق صغيرًا. من أطوال الجميع أوجد إقرانًا يقلل مجموع فروق الأطوال بين كل الأزواج.

الإدخال

  • السطر 1: صحيح $N$.
  • الأسطر $2..N+1$: صحيح بكل سطر لطول ذكر.
  • الأسطر $N+2..2N+1$: صحيح بكل سطر لطول أنثى.

الإخراج

  • السطر 1: صحيح لمجموع فروق الأطوال في إقران أمثل.

أمثلة

الإدخال 1

4
2
8
5
5
1
4
10
7

الإخراج 1

6

ملاحظة

الإدخال

4 ذكور أطوالها 2,8,5,5 و4 إناث أطوالها 1,4,10,7.

شرح — الإخراج

أفضل أزواج الأطوال: 2-1، 8-10، 5-4، 5-7. مجموع الفروق 6.

صاحب المسألة: Brian Dean، 2004

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.