东大OJ-Max Area
1034: Max Area
时间限制: 1 Sec 内存限制: 128 MB
提交: 40 解决: 6
[提交][状态][讨论版]
题目描述
输入
输出
样例输入
2 4 0 1 3 5 1 2 3 4 6 14 0 5 4 6 8 1 5 6 2 4 3
样例输出
15.00 59.00
#include<stdio.h>
void sort(double *a, int from, int to){if (to <= from)return;int i = from, j = to;double k = a[from];while (1){while (a[j] > k)j--;if (j == i)break;a[i] = a[j];a[j] = k;i++;while (a[i] < k)i++;if (j == i)break;a[j] = a[i];a[i] = k;j--;}sort(a, from, i - 1);sort(a, i + 1, to);
}
int main()
{//freopen("in.txt", "r", stdin);int t;scanf("%d", &t);while (t-- > 0){int n;scanf("%d", &n);double x[5001];double y[5001];double z[5001];int i;for (i = 0; i < n; i++)scanf("%lf", &x[i]);for (i = 0; i < n; i++)scanf("%lf", &y[i]);sort(x, 0, n - 1);for (i = 1; i < n - 1; i++)z[i] = x[i + 1] - x[i - 1];z[0] = x[1] - x[0];z[n - 1] = x[n - 1] - x[n - 2];sort(z, 0, n - 1);sort(y, 0, n - 1);double ans = 0;for (i = 0; i < n; i++)ans += z[i] * y[i];printf("%.2lf\n", ans / 2);}return 0;
}
/*破东大OJ题里没说清楚,点是double类型,那个m是5000可能.若问这道题怎么做,第一关,走两步,列出式子;第二关,必须知道一个不等式:顺序>乱序>逆序例如:a={1,2,3}b={4,5,6}则1*4+2*5+3*6>乱序>1*6+2*5+1*4*/
转载于:https://www.cnblogs.com/weiyinfu/p/5013902.html
东大OJ-Max Area相关推荐
- [Leetcode] Max Area of Island 最大岛屿面积
Max Area of Island 最新更新请见:https://yanjia.me/zh/2019/02/... Given a non-empty 2D array grid of 0's an ...
- C#LeetCode刷题之#695-岛屿的最大面积( Max Area of Island)
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3736 访问. 给定一个包含了一些 0 和 1的非空二维数组 gr ...
- [swift] LeetCode 695. Max Area of Island
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...
- [Swustoj 24] Max Area
Max Area 题目描述: 又是这道题,请不要惊讶,也许你已经见过了,那就请你再来做一遍吧.这可是wolf最骄傲的题目哦. 在笛卡尔坐标系正半轴(x>=0,y>=0)上有n个点,给出了这 ...
- LeetCode 695. Max Area of Island
LeetCode 695. Max Area of Island Given a non-empty 2D array grid of 0's and 1's, an island is a grou ...
- LeetCode - 695. Max Area of Island (Java)
R.C记录矩阵行列 可以将邻接矩阵转为邻接表来做,即要将二维数组转换为一维数组: 将二维坐标转化为一维坐标: V = x * C + y 若将一维坐标转化为二维坐标: x = V / C y = V ...
- LeetCode 695 Max Area of Island
题目: Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) ...
- leetcode 695. Max Area of Island | 695. 岛屿的最大面积(DFS)
题目 https://leetcode.com/problems/max-area-of-island/ 题解 class Solution {int M, N;public int maxAreaO ...
- LeetCode 695. Max Area of Island javascript解决方案
题意: 寻找最大岛. leetcode.com/problems/ma- 传入: [[0,0,1,0,0,0,0,1,0,0,0,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], ...
- Leetcode695.Max Area of Island岛屿的最大面积
给定一个包含了一些 0 和 1的非空二维数组 grid , 一个 岛屿 是由四个方向 (水平或垂直) 的 1 (代表土地) 构成的组合.你可以假设二维矩阵的四个边缘都被水包围着. 找到给定的二维数组中 ...
最新文章
- Alpha fold: 人工智能在蛋白质结构预测上跑赢人类的启示
- OpenGL和D3D的区别
- linux安卓双系统板子,安卓迷你 PC 主机只要 109 美元,支持 Android 和 Linux 双系统...
- uni-app 更新包提示HTML5+Runtime缺少升级包manifest.json中配置的模块:payment
- NSLog中格式符列表
- 使用EF.Core将同一模型映射到多个表
- aws dynamodb_DynamoDB备忘单–您需要了解的有关2020 AWS认证开发人员助理认证的Amazon Dynamo DB的所有信息
- python docx 字体大小_Python操作Word的入门教程
- Android_自定义水波纹菜单弹出效果
- Insyde uefi 隐藏设置_文件隐藏工具Wise Folder Hider Pro便携版分享
- Kramdown 配置不当引发 GitHub Pages 多个 RCE,得 $2.5万($6.1万系列之二)
- 【重点 递归版】剑指offer——面试题16:反转链表
- Splash args 属性
- Flowable入门系列文章187 - 高并发性的UUID ID生成器和多租户
- matlab 异常,Matlab 2017b 异常信息。程序奔溃。
- 如何只用HTML创建一个时间计划表?
- html页面加载蒙版,HTML / CSS - 在图像上创建alpha蒙版
- 同时定位与地图创建综述
- 间隔层设备和过程层简介
- 关于树状图画法的分析