东大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 (代表土地) 构成的组合.你可以假设二维矩阵的四个边缘都被水包围着. 找到给定的二维数组中 ...
最新文章
- 首次成功实施 XSS 攻击,盗取目标网站大量 VIP 帐号
- JAVA 1.2(原生数据类型 Primitive Data Type)
- DLL入门浅析(5)——使用DLL在进程间共享数据
- linux系统wget、curl终端命令行获取公网ip地址及其他网络信息
- mysql innodb的索引基本入门
- python群发邮件1000人-python读取excel群发邮件(一)
- c++之使用std::sort对坐标进行排序
- JAVA有没有比robot更好用的_使用Java/Python提高工作效率01-Java Robot类
- 2017百度之星初赛
- arm9处理器 java_ARM处理器系列介绍
- mysql姓名三位随机_Mysql之生成随机数,随机字符串,随机姓名
- 简单的理解unicode和utf-8的关系
- 要不是这些沙雕插件,我早就被公司开除了。
- 【DM】教你用JDBC连接达梦数据库并进行增删改查
- 系统时不变性与因果性的判断总结
- 深度优先搜索(c++)
- 破解某助手刺探功能---第二篇smali代码实现
- 软件加密系统Themida应用程序保护指南(九):通过命令行进行保护
- 传智播客上海java培训就业班 视频教程
- 基于51单片机的电子秤proteus仿真设计
热门文章
- laravel配置加解密
- python 绘制柱状图
- [C++] 头文件中的#ifndef,#define,#endif以及#pragma用法
- MC新手入门(十三)------ 添加游戏角色
- POJ 2723 2-SAT
- Java连接并操作SQLServer数据库
- 实战篇:如何建设企业的营销管理和分析平台
- python学习精华——成长篇
- html文档中怎么区分节点对象节点类型,JavaScript文档对象模型-Element类型
- python自带模块可以控制鼠标吗_python自带模块模拟鼠标和键盘操作