問題一覧 > 通常問題

No.3604 Min of Max of Div of Sum

レベル : / AI推定難易度 : 1725 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 39
作問者 : kazuppa / テスター : ぽえ
お気に入りにしたユーザー ProblemId : 13783 / 自分の提出
問題文最終更新日: 2026-08-05 23:27:02
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 507 オムニバス (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$ and sequences of positive integers $(A_1,A_2,\dotsc,A_N)\ ,\ (B_1,B_2,\dotsc,B_N)$.

Find $\displaystyle\min_{1\leq k\leq N} \max_{1\leq l\leq k\leq r\leq N} \frac{\sum_{i=l}^r A_i}{\sum_{i=l}^r B_i}$.

Constraints

  • $1\leq N\leq 10^5$
  • $1\leq A_i,B_i\leq 10^9$
  • All input values are integers.

Input

$N$
$A_1\ A_2\ \dotsc\ A_N$
$B_1\ B_2\ \dotsc\ B_N$

Output

Output the answer on one line.

Your answer is judged as correct if its absolute or relative error from the true value is at most $10^{-6}$.

Sample

Sample 1
Input
3
1 2 3
3 2 1
Output
1

For $k=1$, the pairs $(l,r)$ satisfying the condition are $(1,1),(1,2),(1,3)$, and their values of $\frac{\sum_{i=l}^r A_i}{\sum_{i=l}^r B_i}$ are $\frac{1}{3},\frac{3}{5},1$, so $\displaystyle\max_{1\leq l\leq k\leq r\leq N} \frac{\sum_{i=l}^r A_i}{\sum_{i=l}^r B_i}=1$.

For $k=2$, the pairs $(l,r)$ satisfying the condition are $(1,2),(1,3),(2,2),(2,3)$, and their values of $\frac{\sum_{i=l}^r A_i}{\sum_{i=l}^r B_i}$ are $\frac{3}{5},1,1,\frac{5}{3}$, so $\displaystyle\max_{1\leq l\leq k\leq r\leq N} \frac{\sum_{i=l}^r A_i}{\sum_{i=l}^r B_i}=\frac{5}{3}$.

For $k=3$, the pairs $(l,r)$ satisfying the condition are $(1,3),(2,3),(3,3)$, and their values of $\frac{\sum_{i=l}^r A_i}{\sum_{i=l}^r B_i}$ are $1,\frac{5}{3},3$, so $\displaystyle\max_{1\leq l\leq k\leq r\leq N} \frac{\sum_{i=l}^r A_i}{\sum_{i=l}^r B_i}=3$.

Therefore, the answer is $\min(1,\frac{5}{3},3)=1$, so output $1$.

Sample 2
Input
3    
999999998 999999999 1000000000
3 2 1
Output
499999999.5

Sample 3
Input
6
1 6 9 2 3 1
4 1 1 8 9 2
Output
1

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。