#C2651. Bird Flight Analysis

    ID: 45991 Type: Default 1000ms 256MiB

Bird Flight Analysis

Bird Flight Analysis

In this problem, birds form groups during migration, and each bird is characterized by its energy level. The group’s strength is defined as the sum of a contiguous subarray with the maximum sum. In other words, given an array \(a_1, a_2, \ldots, a_n\), the strength is given by

\( \max_{1 \le i \le j \le n} \sum_{k=i}^{j} a_k \)

Additionally, the weakest link of the group is defined as the minimum energy among all birds, i.e. \( \min\{a_1, a_2, \ldots, a_n\} \).

You are given \(T\) test cases. For each test case, you are given the number of birds in the group and a list of their energy levels. Your task is to calculate and output the group strength and the weakest link for each test case.

inputFormat

The input consists of multiple lines:

  • The first line contains an integer \(T\), the number of test cases.
  • For each test case:
    • The first line contains an integer \(N\), the number of birds.
    • The second line contains \(N\) space-separated integers representing the energy levels of the birds.

outputFormat

For each test case, output a single line containing two integers separated by a space: the first integer is the strength of the group (maximum subarray sum) and the second is the weakest link (minimum energy value).

## sample
2
9
-2 1 -3 4 -1 2 1 -5 4
3
-1 -2 -3
6 -5

-1 -3

</p>