HDU--杭电--3415--Max Sum of Max-K-sub-sequence--队列--双向队列
Max Sum of Max-K-sub-sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4883 Accepted Submission(s): 1780
Now your job is to calculate the max sum of a Max-K-sub-sequence. Max-K-sub-sequence means a continuous non-empty sub-sequence which length not exceed K.
Then T lines follow, each line starts with two integers N , K(1<=N<=100000 , 1<=K<=N), then N integers followed(all the integers are between -1000 and 1000).
6 3
6 -1 2 -6 5 -5
6 4
6 -1 2 -6 5 -5
6 3
-1 2 -6 5 -5 6
6 6
-1 -1 -1 -1 -1 -1
7 1 3
7 6 2
-1 1 1
用两种写法弄过,一种调用STL双向队列,一种是直接数组模拟,感觉模拟麻烦点但是耗时很少,双向队列每次都是调用的函数,所以耗时多。
STL双向队列:(734MS)
;
}
用数组模拟双向队列:(187MS)
;
}
HDU--杭电--3415--Max Sum of Max-K-sub-sequence--队列--双向队列的更多相关文章
- 『ACM C++』HDU杭电OJ | 1415 - Jugs (灌水定理引申)
今天总算开学了,当了班长就是麻烦,明明自己没买书却要带着一波人去领书,那能怎么办呢,只能说我善人心肠哈哈哈,不过我脑子里突然浮起一个念头,大二还要不要继续当这个班委呢,既然已经体验过就可以适当放下了吧 ...
- 一个人的旅行 HDU杭电2066【dijkstra算法 || SPFA】
pid=2066">http://acm.hdu.edu.cn/showproblem.php? pid=2066 Problem Description 尽管草儿是个路痴(就是在杭电 ...
- find the safest road HDU杭电1596【Dijkstra || SPFA】
pid=1596">http://acm.hdu.edu.cn/showproblem.php?pid=1596 Problem Description XX星球有非常多城市,每一个城 ...
- 『ACM C++』HDU杭电OJ | 1418 - 抱歉 (拓扑学:多面体欧拉定理引申)
呕,大一下学期的第一周结束啦,一周过的挺快也挺多出乎意料的事情的~ 随之而来各种各样的任务也来了,嘛毕竟是大学嘛,有点上进心的人多多少少都会接到不少任务的,忙也正常啦~端正心态 开心面对就好啦~ 今天 ...
- hdu杭电1856 More is better【并查集】
Problem Description Mr Wang wants some boys to help him with a project. Because the project is rathe ...
- Sum It Up POJ 1564 HDU 杭电1258【DFS】
Problem Description Given a specified total t and a list of n integers, find all distinct sums using ...
- Advanced Fruits HDU杭电1503【LCS的保存】
Problem Description The company "21st Century Fruits" has specialized in creating new sort ...
- 杭电oj_2058——The sum problem(java实现)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2058 思路:等差数列公式变形:sum = a1 * len + len *(len -1)/2 抽象成 ...
- 畅通project再续 HDU杭电1875 【Kruscal算法 || Prim】
Problem Description 相信大家都听说一个"百岛湖"的地方吧.百岛湖的居民生活在不同的小岛中.当他们想去其它的小岛时都要通过划小船来实现.如今政府决定大力发展百岛湖 ...
- 杭电 5053 the Sum of Cube(求区间内的立方和)打表法
Description A range is given, the begin and the end are both integers. You should sum the cube of al ...
随机推荐
- Hack 语言学习/参考---1.3 Summary
Summary Hack provides the following, non-exhaustive list of features: Ability to annotate function a ...
- Struts2_2_第一Struts2应用
web.xml文件的配置与1同样. 1)HelloWorld类的代码: public class HelloWorldAction { private String message; public S ...
- MVC应用程序使用Wcf Service
原文:MVC应用程序使用Wcf Service 前一篇Insus.NET有演示过MVC应用程序使用Web Service, 此篇Insus.NET想继续演示Service,不过是WCF Service ...
- ubuntu eclipse android搭建
1.eclipse加入android adt: 终端:sudo gedit /etc/hosts 加入: #for android 173.194.72.93 dl.google.com 173.19 ...
- 大约xib连接错误bug正确
今天code什么时候,发现xib除了加载问题,研究发现的一个问题 在连接的时候, object一定要选择,您连接view,代替 File's Owner 版权声明:本文博客原创文章,博客,未经同意,不 ...
- 真懂JavaScript吗
你真懂JavaScript http://www.cnblogs.com/elegance/p/4195593.html 看了汤姆大叔的“你真懂JavaScript吗?”,里面有5道题目,我都一一作了 ...
- PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings.
有三种解决办法: 1. php文件中设置时区 <?php date_default_timezone_set('Asia/Shanghai'); echo strtotime('2012-9-3 ...
- bootstrap基本标签总结2
[布局]bootstrap基本标签总结2 缩略图 <div class="container"> <div class="row"> ...
- npm err错误
npm ERR!无法安装任何包的解决办法 通过config命令: npm config set registry http://registry.cnpmjs.org
- 快速构建Windows 8风格应用10-设备方向
原文:快速构建Windows 8风格应用10-设备方向 本篇博文主要介绍常用支持Windows 8操作系统设备的方向.如何获取当前设备方向.DisplayProperties类. 常用支持Window ...