Universal Cup Judging System

Universal Cup

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

題目描述

你是前往重慶參加 CCPC 的學校程式設計競賽隊伍的隊長。為了在比賽後增強團隊凝聚力,你希望組織一次團體聚餐。然而,由於賽前吃火鍋已經耗盡了預算,這頓飯的費用必須由所有參與者平攤(也就是說,如果有 $k$ 個人參加總花費為 $W$ 的聚餐,則每人支付 $\frac{W}{k}$)。

隊伍裡有 $n$ 名同學。每位參加聚餐的同學都會點恰好一道菜。第 $i$ 位同學點的菜價格為 $w_i$。每位同學也有一個預算限制 $r_i$:如果最終平攤的餐費超過了 $r_i$,第 $i$ 位同學就會留在飯店點外送。

作為隊長,你希望最大化參加聚餐的同學人數。你的目標是選擇一個由 $m$ 名同學組成的子集,使得如果他們每個人都點各自的菜,平攤後的費用(這 $m$ 道菜的價格總和除以 $m$)不超過這 $m$ 名被選中的同學中任何人的預算 $r_i$。求 $m$ 的最大可能值。

如果不存在任何滿足 $m \ge 1$ 的子集,請輸出 $0$。

輸入格式

單一測試檔案中包含多筆測試資料。輸入的第一行包含一個整數 $T$($1 \le T \le 10^5$),表示測試資料的組數。

對於每筆測試資料:

  • 輸入的第一行包含一個整數 $n$($1 \le n \le 10^5$),代表同學的數量。
  • 接下來輸入一行 $n$ 個整數,其中第 $i$ 個整數 $w_i$($1 \le w_i \le 10^9$)代表第 $i$ 位同學所點菜品的價格。
  • 然後輸入一行 $n$ 個整數,其中第 $i$ 個整數 $r_i$($1 \le r_i \le 10^9$)代表第 $i$ 位同學願意支付的最高價格。

保證所有測試資料中 $n$ 的總和皆不超過 $10^5$。

輸出格式

對於每筆測試資料,輸出一行包含一個整數,代表答案。

範例

範例輸入 1

2
5
1 2 3 4 5
5 4 3 2 1
10
3 1 4 1 5 9 2 6 5 3
5 8 9 7 9 3 2 3 8 4

範例輸出 1

3
7

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.