QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#12321. 十一道题

统计

你准备了一场包含 $n$ 道题目的精彩比赛。这场比赛已经在两个训练营中使用过。在每次训练营结束后,你进行了一次快速民意调查,询问参赛者最喜欢哪道题。在第 $i$ 次训练营中,有 $a_{i,j}$ 名参赛者投票给了第 $j$ 道题。

你打算根据这些数据为每次训练营各制作一个饼图。回想一下,饼图是一种圆形统计图,它被分成若干扇形以展示数值比例。在饼图中,每个扇形的弧长(进而其圆心角和面积)与其所代表的数值成正比。

两个饼图必须具有相同的半径,并且都恰好包含 $n$ 个扇形,每个扇形对应一道题目,且每个扇形必须是一个单一的圆扇区。第 $i$ 个扇形的面积必须与相应训练营中第 $i$ 道题的得票数成正比。两个饼图中扇形的旋转角度和排列顺序可以是任意的,且可以不同。

你希望生成的饼图看起来尽可能相似。为了有一个客观的标准,你定义两个饼图的相似度如下:假设对应于第 $i$ 道题的扇形被涂成颜色 $i$。将一个饼图叠放在另一个饼图上,使它们的边界重合。饼图的相似度定义为两个饼图中颜色相同的区域面积之和与饼图总面积的比值。注意,饼图的相似度与它们的半径无关。

请找到一种绘制饼图的方法,以最大化它们的相似度。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 11$),表示题目数量。

接下来的 $n$ 行,每行包含两个整数 $a_{1,j}$ 和 $a_{2,j}$ ($1 \le a_{i,j} \le 10^6$),分别表示第 $j$ 道题在第一次和第二次训练营中的得票数。

输出格式

输出饼图可能达到的最大相似度。你的答案必须精确到绝对误差不超过 $10^{-9}$。

样例

输入格式 1

2
3 2
2 2

输出格式 1

0.9

输入格式 2

4
3 7
2 1
4 5
2 6

输出格式 2

0.333333333333333

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.