欧姆龙编程竞赛 2026(第 479 场 AtCoder Beginner Contest)
G
调谐
Tuning
AtCoder
⌀ 2386
原题
← F→

调谐AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

You are given length-$N$ integer sequences $A=(A_1,A_2,\dots,A_N)$ and $B=(B_1,B_2,\dots,B_N)$. Consider length-$N$ sequences of rational numbers $c=(c_1,c_2,\dots,c_N)$ and $d=(d_1,d_2,\dots,d_N)$ that satisfy the following condition.

给定长度为 $N$ 的整数序列 $A=(A_1,A_2,\dots,A_N)$ 和 $B=(B_1,B_2,\dots,B_N)$。 考虑满足以下条件的长度为 $N$ 的有理数序列 $c=(c_1,c_2,\dots,c_N)$ 和 $d=(d_1,d_2,\dots,d_N)$。AI (CI翻译)

  • $(A_i+c_i)(B_j+d_j)=(A_j+c_j)(B_i+d_i)$ for all $1 \le i,j \le N$.
  • 对于所有 $1 \le i,j \le N$,都有 $(A_i+c_i)(B_j+d_j)=(A_j+c_j)(B_i+d_i)$。
AI (CI翻译)

Find the minimum possible value of $\displaystyle \sum_{i=1}^{N} \left ( |c_i|+|d_i| \right )$.

求 $\displaystyle \sum_{i=1}^{N} \left ( |c_i|+|d_i| \right )$ 的最小可能值。AI (CI翻译)

It can be proved that the answer to this problem can be uniquely represented as an irreducible fraction $p/q$ with a positive denominator and a non-negative numerator. Output these $p$ and $q$.

可以证明,本题的答案可以唯一表示为分母为正、分子非负的最简分数 $p/q$。 输出这两个整数 $p$ 和 $q$。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • All input values are integers.
  • $2 \le N \le 2 \times 10^5$
  • $|A_i|, |B_i| \le 10^6$
  • 所有输入值均为整数。
  • $2 \le N \le 2 \times 10^5$
  • $|A_i|, |B_i| \le 10^6$
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入通过标准输入以如下格式给出:AI (CI翻译)

N
A_1 A_2 \dots A_N
B_1 B_2 \dots B_N

N
A_1 A_2 \dots A_N
B_1 B_2 \dots B_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

When the answer to this problem is represented as an irreducible fraction $p/q$ with a positive denominator and a non-negative numerator, output it in the following format:

将本题的答案表示为分母为正、分子非负的最简分数 $p/q$,按如下格式输出:AI (CI翻译)

p q

p q
AI (CI翻译)

样例

Input #1
3
4 1 -8
3 1 -6
Output #1
1 4
For example, you can set $c=(0,0,0),d=(0,-\frac{1}{4},0)$, which achieves $\sum_{i=1}^{N} \left ( |c_i|+|d_i| \right ) = \frac{1}{4}$. Also, $\sum_{i=1}^{N} \left ( |c_i|+|d_i| \right )$ cannot be made smaller than this.
Input #2
2
2 2
3 3
Output #2
0 1
If the answer is $0$, it is represented as $0/1$, so output `0 1`.
Input #3
10
855263 -919070 120736 -779959 -789624 789495 -541451 139160 -406547 32421
-612084 -707431 843213 834659 -424146 549941 -799392 -553082 732456 357127
Output #3
635454493436 120459
题目信息
题号
abc479_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。