QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#18127. Hikoutei

Statistics

الوصف

«بالنسبة للمسائل التي لا تعرف كيف تحلها، فقط أرسل شيئاً عشوائياً. من يدري، ربما ينجح الأمر.»

تُعطى مصفوفة أعداد بأبعاد $n \times m$، ويمكنك إعادة ترتيب الأعداد في كل صف بشكل تعسفي بحيث يتم تعظيم مجموع القيم الصغرى لجميع الأعمدة.

رسمياً، لتكن المصفوفة المعاد ترتيبها هي $A$. عظّم المقدار $\sum_{j=1}^m (\min_{i=1}^n A_{i,j})$.

تحتاج إلى طباعة هذه القيمة العظمى.

«في كثير من الأحيان، كون الأمور تسير عكس رغباتنا هو ببساطة القاعدة في الحياة.»

الإدخال

يحتوي السطر الأول من الإدخال على عدد حالات الاختبار $T$ ($1 \leq T \leq 10^5$).

لكل حالة اختبار، يحتوي السطر الأول على عددين صحيحين موجبين $n, m$ ($1 \leq n, m \leq 1000$)، يمثلان حجم المصفوفة.

تحتوي الأسطر الـ $n$ التالية في كل منها على $m$ من الأعداد الصحيحة، التي تمثل الأعداد $A_{i,j}$ في المصفوفة ($0 \leq A_{i,j} \leq 10^9$).

من المضمون أن مجموع $n \cdot m$ عبر جميع حالات الاختبار لا يتجاوز $10^6$.

الإخراج

لكل حالة اختبار، اطبع عدداً صحيحاً واحداً في سطر مستقل يمثل الإجابة.

أمثلة

الإدخال 1

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

الإخراج 1

5
5
4

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.