#include <cstdio>
#include <stack>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=5e4+10;
struct asd
{
LL pre;
LL next;
LL num;
};
int n;
LL ww[N]; int main()
{
int T,cas=1;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=1; i<=n; i++)
scanf("%lld",&ww[i]); stack<asd>q;
asd tmp;
tmp.num=ww[1];
tmp.next=tmp.pre=1;
q.push(tmp);
LL ans=0;
for(int i=2; i<=n; i++)
{
asd tmp1;
tmp1.num=ww[i];
tmp1.pre=tmp1.next=1;
while(!q.empty()&&tmp1.num<q.top().num)
{
tmp=q.top();
q.pop();
tmp1.pre+=tmp.pre;
if(!q.empty())
q.top().next+=tmp.next;
ans=max(tmp.num*(tmp.pre+tmp.next-1),ans);
}
q.push(tmp1);
} while(!q.empty())
{
tmp=q.top();
q.pop();
if(!q.empty())
q.top().next+=tmp.next;
ans=max(ans,(tmp.next+tmp.pre-1)*tmp.num);
} printf("Case %d: %lld\n",cas++,ans);
}
return 0;
}

最新文章

  1. [Copy]Bird&#39;s booklist
  2. 快速破解哈希密文findmyhash
  3. 同网段下,windows自带远程桌面连接
  4. mysql 修改字符集
  5. X光机的原理及构造
  6. js中的屏蔽
  7. Storm官方文档翻译之创建Storm项目
  8. jq获取被选中的option的值。jq获取被选中的单选按钮radio的值。
  9. VS2015远程调试
  10. Swift基础之init方法,实例方法,类方法(静态方法)的使用(多标签Demo)
  11. vscode中vue代码颜色插件
  12. Linux内核分析第七次作业
  13. MySQL中MyISAM与InnoDB区别及选择
  14. CSS之透视perspective属性
  15. Learning to rank相关的pointwise,pairwise,listwise
  16. 进度条ProgressBar
  17. 【PAT Advanced Level】1015. Reversible Primes (20)
  18. zookeeper 数据节点的增删改查
  19. 虚拟机VMware12.0安装centos 6.5+VMware中虚拟机网络模式区分
  20. module_param 用于动态开启/关闭 驱动打印信息

热门文章

  1. erlang防止反编译
  2. 2016/07/07 wamp中apache2.4.9允许外部访问的配置 重点是版本 版本不同配置效果不同
  3. 51 NOD 1753 相似子串 字符串hash
  4. linux修改进程的名字
  5. yum 工作原理
  6. Mixtures of Gaussians and the EM algorithm
  7. Recurrent neural networks are very powerful, because they combine two properties
  8. PAT 天梯赛 L1-049. 天梯赛座位分配 【循环】
  9. python 实用pickle序列化
  10. Emscripten实现把C/C++文件转成wasm,wast(wasm的可读形式),llvm字节码(bc格式),ll格式(llvm字节码的可读形式)并执行wasm