全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
To the MaxTime Limit:1000MSMemory Limit:10000KTotal Submissions:32984Accepted:17276DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that rectangle. In this problem the sub-rectangle with the largest sum is referred to as the maximal sub-rectangle.As an example, the maximal sub-rectangle of the array:0 -2 -7 09 2 -6 2-4 1 -4 1-1 8 0 -2is in the lower left corner:9 2-4 1-1 8and has a sum of 15.InputThe input consists of an N * N array of integers. The input begins with a single positive integer N on a line by itself, indicating the size of the square two-dimensional array. This is followed by N2 integers separated by whitespace (spaces and newlines). These are the N2 integers of the array, presented in row-major order. That is, all numbers in the first row, left to right, then all numbers in the second row, left to right, etc. N may be as large as 100. The numbers in the array will be in the range -127,127.OutputOutput the sum of the maximal sub-rectangle.Sample Input40 -2 -7 0 9 2 -6 2-4 1 -4 1 -18 0 -2Sample Output15当然是dp了只是如何去分解每一步,成了问题。其实把它转化成求一位数组的最大子序列问题就行代码如下:#include#include#includeusing namespace std;const int MAX=105;int aMAXMAX;int tMAX;int n;int get() /最大和子序列函数 int m=0,te=0; for(int i=1;im) m=te; if(ten) for(int i=1;i=n;+i) for(int j=1;j=n;+j) scanf(%d,&aij); int num=0; for(int i=1;i=n;+i) / i行开始 memset(t,0,sizeof(t); for(int j=i;j=n;+j) /j行结束
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025湖南省粮油食品进出口集团有限公司总部招聘3人笔试备考题库及答案解析(夺冠)
- 2025湖南岳阳市岳阳楼区卫健系统事业单位公开招聘工作人员23人备考题库含答案解析(夺冠)
- 心脏代谢组学:预后评估的精准策略
- 2024年丽江市遴选公务员考试真题汇编及答案解析(夺冠)
- 心肌再生干细胞治疗的临床前评价
- 2024年石嘴山市遴选公务员笔试真题汇编含答案解析(夺冠)
- 2023年辽宁省直属机关遴选公务员笔试真题汇编附答案解析
- 2025年种业技术秘密转让协议
- 2025湖北宜昌市五峰土家族自治县招聘县城社区专职人员6人备考题库有完整答案详解
- 青岛远洋船员学院航海学讲义08-2航海六分仪
- 2025陕西交控集团社会招聘历年真题库附答案解析
- 协议婚约解除协议书
- 2025-2026学年人教版(新教材)小学信息科技四年级全一册第一学期期末质量检测卷附答案(3套)
- 2026年电镀工(中级)自测试题及答案
- 介入导管室护理管理
- 贵州省公务用车监督管理信息系统用户操作手册
- 口腔科拔牙后出血处理措施
- 暖通班组培训课件
- 电厂装置性违章培训课件
- 胃癌病人的PTT课件
- 梁衡《把栏杆拍遍》课件
评论
0/150
提交评论