HackerRank# Bricks Game
2024-09-04 12:29:39
DP很简单,懒得压缩空间了,反正都能过
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; #define MAX_N 100008 int T, N;
long long score[MAX_N];
long long sum[MAX_N];
long long best[MAX_N]; int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
cin >> T;
while (T--) {
cin >> N;
memset(sum, , sizeof(sum));
memset(best, , sizeof(best));
for (int i = ; i <= N; i++)
cin >> score[i];
for (int i = N; i >= ; i--)
sum[i] = score[i] + sum[i + ];
best[N] = sum[N];
best[N - ] = sum[N - ];
best[N - ] = sum[N - ];
for (int i = N - ; i >= ; i--)
for (int j = ; j <= ; j++)
best[i] = max(best[i], sum[i] - best[i + j]);
cout << best[] << endl;
}
return ;
}
最新文章
- User interface
- 20款最佳用户体验的Sublime Text 2/3主题下载及安装方法
- MS SQL 合并结果集并求和 分类: SQL Server 数据库 2015-02-13 10:59 92人阅读 评论(0) 收藏
- dolby逝世:纪念一下
- fragment (1)简单示例:定义,界面配置,fragment之间的跳转
- UITableViewStyleGrouped 模式下 headview 多出一块高度问题
- Determining IP information for eth0... failed; no link present. Check cable?
- BZOJ2442: [Usaco2011 Open]修剪草坪
- Cocos2d-x win7 + vs2010 配置图文详解(亲测)
- 干货分享:Neutron的PPT,帮助你理解Neutron的各种细节
- MYSQL动态查询拼接的表名的SQL脚本实现(MYSQL动态执行SQL脚本)
- 2.获取公开的漏洞信息-查询还有哪些系统补丁未堵住-查询exp
- PB测款方法 店铺运费模板 设置
- day 5,格式化输出,for,while, break,continue,列表
- (网页)textarea去掉回车换行
- January 24th, 2018 Week 04th Wednesday
- 全球最大的3D数据集公开了!标记好的10800张全景图
- H5之localStorage,sessionStorage
- time_base
- python 字符串编码 ,区别 utf-8 和utf-8-sig
热门文章
- 洛谷 P2947 [USACO09MAR]仰望Look Up
- Gym 100342E 	Minima (暴力,单调队列)
- CSAPP lab1 datalab-handout
- vue 数组更新 this.$set(this.dataList, data.index, data.data)
- NoSuchBeanDefinitionException: No qualifying bean of type &#39;com.bj186.ssm.mapper.EmployeeMapper&#39; available: expected at least 1 bean which qualifies as autowire candidate
- javase(11)_juc并发库
- JavaWeb项目中集成Swagger API文档
- 计算机/ARM 系统
- Python9-迭代器-生成器-day13
- Python9-集合-day7