华中农业大学第五届程序设计大赛网络同步赛-A
Problem A: Little Red Riding Hood
Time Limit: 1 Sec Memory Limit: 1280 MB
Submit: 860 Solved: 133
[Submit][Status][Web Board]
Description
Input
k (
Output
Each group of outputs occupies one line and there are one number indicates the sum of the largest beauty degrees of flowers Little Red Riding Hood can pick.
Sample Input
1
3 1
2 1 3
Sample Output
5
HINT
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int a[], dp[]; int main()
{
int T, n, k;
scanf("%d", &T);
while(T--)
{
scanf("%d%d", &n, &k);
for(int i = ; i < n; i++){
scanf("%d", &a[i]);
dp[i] = a[i];
}
int mx = dp[];
int ans = ;
for(int i = k+; i < n; i++)
{
mx = max(mx, dp[i-k-]);
dp[i] = a[i] + mx;
if(ans < dp[i])ans = dp[i];
}
printf("%d\n", ans);
} return ;
}
华中农业大学第五届程序设计大赛网络同步赛-A的更多相关文章
- 华中农业大学第五届程序设计大赛网络同步赛-L
L.Happiness Chicken brother is very happy today, because he attained N pieces of biscuits whose tast ...
- 华中农业大学第五届程序设计大赛网络同步赛-K
K.Deadline There are N bugs to be repaired and some engineers whose abilities are roughly equal. And ...
- 华中农业大学第五届程序设计大赛网络同步赛-G
G. Sequence Number In Linear algebra, we have learned the definition of inversion number: Assuming A ...
- 华中农业大学第五届程序设计大赛网络同步赛-D
Problem D: GCD Time Limit: 1 Sec Memory Limit: 1280 MBSubmit: 179 Solved: 25[Submit][Status][Web B ...
- [HZAU]华中农业大学第四届程序设计大赛网络同步赛
听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I.然后去做作业了…… #include <algorithm> #include <iostream> #include ...
- (hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C
题目链接:http://acm.hzau.edu.cn/problem.php?id=18 题意是给你两个长度为n的数组,a数组相当于1到n的物品的数量,b数组相当于物品价值,而真正的价值表示是b[i ...
- 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列
Problem G: Array C Time Limit: 1 Sec Memory Limit: 128 MB Description Giving two integers and and ...
- 华中农业大学第四届程序设计大赛网络同步赛 J
Problem J: Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1766 Solved: 299[Subm ...
- 华中农业大学第四届程序设计大赛网络同步赛 I
Problem I: Catching Dogs Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1130 Solved: 292[Submit][St ...
随机推荐
- [转载]java开发中的23种设计模式
原文链接:http://blog.csdn.net/zhangerqing 设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反 ...
- 爬虫:Scrapy5 - 选择器Selectors
当抓取网页时,常见的任务是从HTML源码中提取数据.现有的一些库可以达到这个目的: BeautifulSoup lxml Scrapy 提取数据有自己的一套机制.它们被称作选择器(seletors), ...
- Jenkins配置自动打包 -- 遇到的坑
1.把gradle路径设为本地路径 Jenkins部署在远程linux服务器上,使用git将代码下载到服务器路径下后,无法使用gradle命令 因为默认配置都是gradle同步时 实时从网上下载,进入 ...
- 剑指offer八之跳台阶
一.题目 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 二.思路 a.如果两种跳法,1阶或者2阶,那么假定第一次跳的是一阶,那么剩下的是n-1个台阶,跳法 ...
- Quartz.NET基础知识概述
Quartz.NET是什么 由于我现在使用的Quartz.NET2.2版本,相对2.x变化不大,主要是相对于1.x更新了很多东西,如下基础知识摘录网络. Quartz.NET是一个开源的作业调度框架, ...
- 解决IDEA中进行maven install报:系统资源不足的问题
一.背景 最近在idea中使用maven对公司的项目进行install的时候老是出现系统资源不足的问题导致install失败,在网上搜索也没找到很好的答案,自己不断摸索,最终在idea的配置里面找到了 ...
- Maven <Profiles>定义不同环境的参数变量
记录一下 https://blog.csdn.net/qq245282209/article/details/52192115
- postgresql 创建用户并创建数据库
首先通过 sudo -i -u postgres 以管理员身份 postgres 登陆,然后通过 createuser --interactive (-- interactive 是交互式,创建过程可 ...
- xml Schema include
first.xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs=&q ...
- [转]Linux 微擎系统搭建
本文转自:https://www.cnblogs.com/voidking/p/5296552.html 前言 时隔一年半,再次接触微信公众平台开发.相比于掌上大学.圈里.微站ABC.图灵机器人.小i ...