CCF 模拟C 找最大矩形+输入输出外挂
http://115.28.138.223:81/view.page?opid=3
统计出连续的最长乘以当前高度,找最大即可
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define within(x,a,b) ((unsigned)((x)-(a))<=((b)-(a)))
using namespace std;
int readint(int *p)
{
int ch;
while(!within(ch=getchar(),'',''))
if(ch == EOF) return EOF;
int rslt = ;
do
rslt=rslt*+(ch-'');
while(within(ch=getchar(),'',''));
*p = rslt;
return ;
}
void out(int a)
{
if(a>)
out(a/);
putchar(a%+'');
}
int a[];
int main()
{
int x;
while(cin>>x)
{
memset(a,,sizeof(a));
int floor=,max=,maxfloor=,looop=,MAXS=;
for(int i=;i<x;i++)
{
readint(&a[i]);
if(a[i]>maxfloor) {maxfloor=a[i];}
}
while(floor<=maxfloor)
{
for(int i=;i<x;i++)
{
if(a[i]>=floor)
{
looop++;
}
else if(a[i]<floor)
{
if(looop>max) max=looop;
looop=;
}
if(looop>max) max=looop;
}
int yy=max*floor;
if(yy>MAXS) MAXS=yy;
floor++;
looop=;
max=;
}
out(MAXS);
cout<<endl;
}
return ;
}
CCF 模拟C 找最大矩形+输入输出外挂的更多相关文章
- CCF 模拟B 无脑循环+输入输出外挂
http://115.28.138.223:81/view.page?opid=2#code 代码一有WA点80分 #include<iostream> #include<cstdi ...
- CCF模拟题 最大的矩形
最大的矩形 时间限制: 1.0s 内存限制: 256.0MB 问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi.这n个矩形构成了一个直方 ...
- CCF模拟试题——最大的矩形 Java
我们先看一下题目: 问题描述 试题编号: 201312-3 试题名称: 最大的矩形 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 在横轴上放了n个相邻 ...
- POJ 1904 King's Quest 强联通分量+输入输出外挂
题意:国王有n个儿子,现在这n个儿子要在n个女孩里选择自己喜欢的,有的儿子可能喜欢多个,最后国王的向导给出他一个匹配.匹配有n个数,代表某个儿子和哪个女孩可以结婚.已知这些条件,要你找出每个儿子可以和 ...
- poj 1904(强连通分量+输入输出外挂)
题目链接:http://poj.org/problem?id=1904 题意:有n个王子,每个王子都有k个喜欢的妹子,每个王子只能和喜欢的妹子结婚,大臣给出一个匹配表,每个王子都和一个妹子结婚,但是国 ...
- CCF CSP 201312-3 最大的矩形
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201312-3 最大的矩形 问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i( ...
- HDU 2993 MAX Average Problem(斜率DP经典+输入输出外挂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 题目大意:给出n,k,给定一个长度为n的序列,从其中找连续的长度大于等于k的子序列使得子序列中的 ...
- zzuli 2130: hipercijevi 链式前向星+BFS+输入输出外挂
2130: hipercijevi Time Limit: 1 Sec Memory Limit: 128 MB Submit: 595 Solved: 112 SubmitStatusWeb B ...
- CCF 模拟试题——出现次数最多的数 官方答案解析及自己写的正确答案
前几天知道的CCF计算机职业资格认证考试,觉得好像比软考含金量高一些,就去了解了一下,做了模拟试题中的 “出现次数最多的数” 这道题,我的算法和官方答案算法不同,个人觉得觉得官方的好一点,没那么繁琐, ...
随机推荐
- Spring MVC学习笔记——用户增删该查和服务器端验证
建立一个动态web项目,起名为SpringMVC_crud 导包,其中包括jstl的一些包等 1.先写一个User.java,是用户类 文件User.java文件 package org.common ...
- JavaWeb学习笔记——XML简介
- HTML学习笔记——图片显示、图片跳转、图片相对路径
1>显示图片.用a标签实现点击图片跳转.地图标签/点击图片上固定区域跳转 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transit ...
- Game Programming Pattern
http://gameprogrammingpatterns.com/contents.html
- Using Flash Builder with Flash Professional
http://help.adobe.com/en_US/flashbuilder/using/WSc5cd04c102ae3e97-6e5d439512e1414e588-8000.html
- Unity3D Multi-Compile Shader
http://www.martinpalko.com/muli-compile-unity/ http://forum.unity3d.com/threads/tutorial-shade-more- ...
- Install Mono and MonoDevelop on Fedora
http://www.mono-project.com/docs/getting-started/install/linux/ http://www.monodevelop.com/download/ ...
- 拍拍装修<a href="" > 搜狐 “兼容模式”下失效,解决办法
代码 <a href="http://www.baidu.com"> <p style="></p> <p style=&quo ...
- 用实例揭示notify()和notifyAll()的本质区别
用实例揭示notify()和notifyAll()的本质区别 收藏 notify()和notifyAll()都是Object对象用于通知处在等待该对象的线程的方法.两者的最大区别在于: notif ...
- mysql dumpfile与outfile函数的区别
一直以为两个函数作用是相同的 经过简单测试发现还是有些区别的 如下表admin mysql> select * from admin; +-----+-----------+-- ...