Logo
(追記) (追記ここまで)

31598번 - Forming Groups 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB141534939.200%

문제

There are $n$ students, numbered from 1ドル$ to $n,ドル who need to form groups for the upcoming hackathon. You are student 1ドル,ドル the captain of the students. Student $i$ has skill level $a_i$.

Students 2ドル$ to $n$ are standing in a line from left to right in order. You can choose to stand in between any two students, to the left of student 2ドル,ドル or to the right of student $n$. You cannot change the order of the $n - 1$ students.

You can also choose the number of groups $k$ ($k > 1$ and $k$ must be a divisor of $n$) to participate in the hackathon. The groups will be numbered from 1ドル$ to $k$. After you have chosen your position and the value of $k,ドル the students will be grouped as follows:

  • The first student from the left will be assigned to group 1ドル$.
  • The second student from the left will be assigned to group 2ドル$.
  • $\dots$
  • The $k$-th student from the left will be assigned to group $k$.
  • The $(k + 1)$-th student from the left will be assigned to group 1ドル$.
  • The $(k + 2)$-th student from the left will be assigned to group 2ドル$.
  • $\dots$
  • The $n$-th student from the left will be assigned to group $k$.

Formally, for each $j$ (1ドル ≤ j ≤ k$) and for each $i$ (0ドル ≤ i < n/k$), the $(i \times k +j)$-th student from the left will be assigned to group $j$. It can be shown that each student will be assigned to exactly one group and all the groups have the same number of students.

The skill level of a group is the sum of the skill levels of the students inside the group. By choosing where you stand as well as the number of groups $k$ optimally, you want to minimize the ratio $x_\max/x_\min$ where

  • $x_\max$ is the skill level of the group with the largest skill level, and
  • $x_\min$ is the skill level of the group with the smallest skill level.

입력

The first line of input contains one integer $t$ (1ドル ≤ t ≤ 100,円 000$) representing the number of test cases. After that, $t$ test cases follow. Each of them is presented as follows.

The first line of a test case contains two integers $n$ and $a_1$ (2ドル ≤ n ≤ 10^6$; 1ドル ≤ a_1 ≤ 1000$). The next line contains $n - 1$ integers $a_2, a_3, \dots , a_n$ (1ドル ≤ a_i ≤ 1000$ for all $i$).

The sum of $n$ across all test cases in one input file does not exceed 10ドル^6$.

출력

For each test case, output one line containing two positive integers $p$ and $q$ such that the minimum ratio is $p/q$. The fraction $p/q$ should be irreducible. In other words, $p$ and $q$ should be coprime.

제한

예제 입력 1

2
4 1
2 1 2
3 10
4 3

예제 출력 1

1 1
10 3

In the first test case, by standing between students 2ドル$ and 3ドル$ (or between students 3ドル$ and 4ドル$) and choosing $k = 2,ドル group 1ドル$ will have the skill level 2ドル + 1$ and group 2ドル$ will have the skill level 1ドル + 2,ドル thus the ratio is 1ドル/1$.

In the second test case, the only choice for the value of $k$ is 3ドル$.

힌트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2024 ICPC Asia Pacific Championship F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /