OUC_Summer Training_ DIV2_#12(DP1) 723
这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列。
先看题好啦。
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
As an example, the maximal sub-rectangle of the array:
0 -2 -7 0
9 2 -6 2
-4 1 -4 1
-1 8 0 -2
is in the lower left corner:
9 2
-4 1
-1 8
and has a sum of 15.
Input
Output
Sample Input
Sample Output
#include<stdio.h>
#include<string.h>
int a[][];
int b[];
int f(int a[],int n);
int main()
{ int i,j,k,n,temp,ans ;
while(scanf("%d",&n) != EOF)
{
for(i = ;i < n;i++)
{
for(j = ;j < n;j++)
scanf("%d",&a[i][j]);
}
temp=ans=-0x7fffff;
for(i = ;i < n;i++)
{
memset(b,,sizeof(b));
for(j = i;j < n;j++)
{
for(k = ;k < n;k++)
{
b[k] += a[j][k];
}
temp = f(b,n);
if(ans < temp) ans =temp;
}
}
printf("%d\n",ans);
} return ;
}
int f(int a[],int n)
{
int max = a[],ans,i,j;
for(i = ;i < n;i++)
{
if(max < a[i])max = a[i];
}
if(max < )return max;
else
{
int sum = ;
for(i = ;i < n;i++)
{
sum += a[i];
if(sum > max)max = sum;
else if(sum < )sum = ;
}
}
return max;
}
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Input
White spaces can occur freely in the input. The input data are correct and terminate with an end of file.
Output
For each set of data the program prints the result to the standard output from the beginning of a line.
Sample Input
6
5 2 1 4 5 3
3
1 1 1
4
4 3 2 1
Sample Output
3
1
1
Hint
#include <iostream>
#include<stdio.h>
using namespace std;
int a[],b[],t;
void dog(int z)
{
int x,y,mid;
x=;
y=t;
while(x<=y)
{
mid=(x+y)/;
if (b[mid]==z) return ;//这里可以不return,令x = mid +1 即可
else
if (b[mid]>z) y=mid-;
else
x=mid+;
}
if (x==t+)//这里就是最大的直接放在后面
{
t++;
b[t]=z;
}
else
b[x]=z;
}
int main() {
int n,i;
while(scanf("%d",&n)!=EOF)
{
for(i=;i<=n;i++)
scanf("%d",&a[i]);
t=;
b[]=a[];
for(i=;i<=n;i++)
{
dog(a[i]);
}
printf("%d\n",t);
}
return ;
}
OUC_Summer Training_ DIV2_#12(DP1) 723的更多相关文章
- OUC_Summer Training_ DIV2_#13 723afternoon
A - Shaass and Oskols Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- OUC_Summer Training_ DIV2_#9 719
其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time L ...
- OUC_Summer Training_ DIV2_#5
这是做的最好的一次了一共做了4道题 嘻嘻~ A - Game Outcome Time Limit:2000MS Memory Limit:262144KB 64bit IO For ...
- OUC_Summer Training_ DIV2_#16 725
今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...
- OUC_Summer Training_ DIV2_#14 724
又落下好多题解啊...先把今天的写上好了. A - Snow Footprints Time Limit:1000MS Memory Limit:262144KB 64bit IO F ...
- OUC_Summer Training_ DIV2_#2之解题策略 715
这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...
- OUC_Summer Training_ DIV2_#7 718
是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS Memory ...
- OUC_Summer Training_ DIV2_#11 722
企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- OUC_Summer Training_ DIV2_#4之数据结构
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS Me ...
随机推荐
- SpringBoot与缓存、消息、检索、任务、安全与监控
一.Spring抽象缓存 Spring从3.1开始定义了org.springframework.cache.Cache和org.springframework.cache.CacheManager接口 ...
- Arcgis js之web墨卡托(3857)转经纬度坐标(4326)
Arcgis js之web墨卡托(3857)转经纬度坐标(4326) 手动转化方法: function mercatorTolonlat(mercator){ var lonlat={x:0,y:0} ...
- oracle数据库(实例)的导出与导入
Oracle数据导入导出常用两种方式: 1.是通过plsql-->tool-->export/import进行dmp文件的导入与导出: 2.使用命令imp/exp执行oracle数据导入与 ...
- 如何使用Marketing Cloud的扩展字段作为搜索条件进行搜索
需求:我在Marketing Cloud的contact模型上用custom field这个应用创建了一个Extension field,名称为微信ID. 现在客户的需求是使用这个字段作为过滤条件进行 ...
- Django—Form组件
Django From简介 我们之前在HTML页面中利用form表单向后端提交数据时,都会写一些获取用户输入的标签并且用form标签把它们包起来. 与此同时我们在好多场景下都需要对用户的输入做校验,比 ...
- 从Windows文件夹到Linux分区
1. 先说几句 如果你, 知道什么是Windows系统 简单使用Windows系统 想要了解或安装Linux 刚接触Linux会有以下疑惑, 什么是分区? 如何建立分区? 怎么安装系统到到D盘? 安装 ...
- String特性之 “字符串驻留池”
1. 字符串驻留池,就是一块与堆区并行的存放字符串对象的内存区,JVM的驻留池机制规定: 在池中创建一个String对象,第二行会先在池中寻找是否有值与"abc"相同的String ...
- 关于swap交换操作的新方法
swap: 在oi中,swap用于交换两个变量的数值. 初学oi时,我们这样操作: 也就是说,需要一个temp变量来寄存x或y的值,因为当一个变量被赋值成为另一个变量时,没有temp它的值会丢失. 貌 ...
- js过滤时间格式
Date.prototype.Format = function(fmt) { //author: meizz var o = { "M+" : this.getMonth()+1 ...
- Python 列表和元组 (2) 持续更新
数据结构就是数据的集合.Python最基本的数据结构就是序列,每个元素都会被分配一个元素的位置,也可以称为索引.注意索引都是从0开始的. Python包含6种内建的序列,分别是列表.元组.字符串.Un ...