A1368 | [COCI-2017_2018-contest6]#2 Cover
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
You are given N points in the coordinate system. They need to be covered with one or more rectangles, such that the following conditions are met:
● The sides of each rectangle are parallel with the coordinate axes, ● The center of each rectangle is in the origin, i.e. point (0, 0), ● Each given point is located either inside of the rectangle or on its boundaries.
Of course, it is possible to cover all the points using only one rectangle, but this rectangle could have a very large surface area. Our goal is to find a selection of required rectangles such that the sum of their surface areas is minimal.
● The sides of each rectangle are parallel with the coordinate axes, ● The center of each rectangle is in the origin, i.e. point (0, 0), ● Each given point is located either inside of the rectangle or on its boundaries.
Of course, it is possible to cover all the points using only one rectangle, but this rectangle could have a very large surface area. Our goal is to find a selection of required rectangles such that the sum of their surface areas is minimal.
输入格式
The first line of input contains the integer N (1 ≤ N ≤ 5000), the number of points.
Each of the following N lines contains two integers X and Y (-50 000 000 ≤ X, Y ≤ 50 000 000, XY ≠ 0), the coordinates of each point.
Each of the following N lines contains two integers X and Y (-50 000 000 ≤ X, Y ≤ 50 000 000, XY ≠ 0), the coordinates of each point.
输出格式
You must output the required minimal sum of surface areas of the rectangles.
输入输出样例
输入 #1
2 1 1 -1 -1
输出 #1
4
输入 #2
3 -7 19 9 -30 25 10
输出 #2
2080
输入 #3
6 1 20 3 17 5 15 8 12 9 11 10 10
输出 #3
760
In test cases worth 40% of total points, it will hold N ≤ 20.
Clarification of the first test case: We choose the rectangle whose opposite angles are the given
points, since it meets the conditions from the task.
Clarification of the second test case: We choose two rectangles with their centers in the origin. The
first is of dimensions 50 x 20 and covers point (25, 10). The second is of dimensions 18 x 60 and
covers the first two points. If we wanted to cover all the points using one rectangle, it would be of
dimensions 50 x 60.
Clarification of the first test case: We choose the rectangle whose opposite angles are the given
points, since it meets the conditions from the task.
Clarification of the second test case: We choose two rectangles with their centers in the origin. The
first is of dimensions 50 x 20 and covers point (25, 10). The second is of dimensions 18 x 60 and
covers the first two points. If we wanted to cover all the points using one rectangle, it would be of
dimensions 50 x 60.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted