1. 程式人生 > 實用技巧 >牛客第八場

牛客第八場

牛客第八場

時間限制:C/C++ 1秒,其他語言2秒
空間限制:C/C++ 262144K,其他語言524288K
64bit IO Format: %lld

題目描述

Tired of boring WFH (work from home), Apollo decided to open a fast food restaurant, called \textbf{Kabaleo Lite}Kabaleo Lite.
The restaurant serves n kinds of food, numbered from 1 to n. The profit for the i-th kind of food is a_ia**i

​. Profit may be negative because it uses expensive ingredients. On the first day, Apollo prepared b_ib**i​ dishes of the i-th kind of food.
The peculiarity of Apollo's restaurant is the procedure of ordering food. For each visitor Apollo himself chooses a set of dishes that this visitor will receive. When doing so, Apollo is guided by the following rules:

  • every visitor should receive at least one dish.
  • each visitor should receive continuous kinds of food started from the first food. And the visitor will receive exactly 1 dish for each kind of food. For example, a visitor may receive 1 dish of the 1st kind of food, 1 dish of the 2nd kind of food, 1 dish of the 3rd kind of food.

What's the maximum number of visitors Apollo can feed? And he wants to know the maximum possible profits he can earn to have the maximum of visitors.

輸入描述:

The first line of the input gives the number of test case, \mathbf{T}T (1 \leq \mathbf{T} \leq 101≤T≤10). \mathbf{T}T test cases follow.
Each test case begins with a line containing one integers n (1 \le n \le 10^51≤n≤105), representing the number of different kinds of food.
The second line contains n space-separated numbers a_iai (-10^9 \le a_i \le 10^9−109≤ai≤109), where a_iai denotes the profit of one dish of the i-th kind.
The third line contains n space-separated numbers b_ibi (1 \le b_i \le 10^51≤bi≤105), where b_ibi denotes the number of the i-th kind of dishes.

輸出描述:

For each test case, output one line containing ``Case\ \#x:\ y\ z''‘‘Case #x: y z′′, where x is the test case number (starting from 1), y is the maximum number of visitors, and z is the maximum possible profits.

示例1

輸入

[複製](javascript:void(0)