HackerRank# Bricks Game
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 ;
}
HackerRank# Bricks Game的更多相关文章
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- 日常小测:颜色 && Hackerrank Unique_colors
题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...
- HackerRank "Square Subsequences" !!!
Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the soluti ...
- HackerRank "Minimum Penalty Path"
It is about how to choose btw. BFS and DFS. My init thought was to DFS - TLE\MLE. And its editorial ...
- HackerRank "TBS Problem" ~ NPC
It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/Charl ...
- HackerRank Extra long factorials
传送门 今天在HackerRank上翻到一道高精度题,于是乎就写了个高精度的模板,说是模板其实就只有乘法而已. Extra long factorials Authored by vatsalchan ...
- HackerRank "Lucky Numbers"
Great learning for me:https://www.hackerrank.com/rest/contests/master/challenges/lucky-numbers/hacke ...
- HackerRank "Playing with numbers"
This is 'Difficult' - I worked out it within 45mins, and unlocked HackerRank Algorithm Level 80 yeah ...
- HackerRank "The Indian Job"
A sly knapsack problem in disguise! Thanks to https://github.com/bhajunsingh/programming-challanges/ ...
随机推荐
- JS判断两个对象相同属性的属性值是否相等
function isObjectValueEqual(a, b) { var aProps = Object.getOwnPropertyNames(a); var bProps = Object. ...
- gcc, g++ - GNU 工程的 C 和 C++ 编译器 (egcs-1.1.2)
总览 (SYNOPSIS) gcc [ option | filename ]... g++ [ option | filename ]... 警告 (WARNING) 本手册页 内容 摘自 GNU ...
- Java的jdbc调用SQL Server存储过程Bug201906131120
如果要查询结果,第一行使用set nocount on;可能可以解决问题.
- 快学UiAutomator创建第一个实例
工具准备 一.准备好java环境(JDK)和安卓环境(SDK.ADT)jdk1.6+ \eclipse\SDK \ADT详情百度,安装java环境 二.打开eclipse 三.创建步骤: 右键新建== ...
- POI把html写入word doc文件
直接把Html文本写入到Word文件 获取查看页面的body内容和引用的css文件路径传入到后台. 把对应css文件的内容读取出来. 利用body内容和css文件的内容组成一个标准格式的Html文本. ...
- SQLyog连接数据库 提示错误plugin caching_sha2_password could not be loaded
1.打开mysql cmd 2.执行语句 ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; # ...
- shell脚本,一个经典题目。
[root@localhost wyb]# cat zhuijiu.sh #!/bin/bash #.写一个脚本执行后,输入名字,产生随机数01-99之间的数字. #.如果相同的名字重复输入,抓到的数 ...
- angular-file-upload 在IE下使用的坑
如果在控件配置里面设置了queueLimit属性为1,就是队列文件个数为1,并且在<input>标签设置里multiple属性. 在IE浏览器上传附件的时候,浏览器会报错“SCRIPT50 ...
- [POJ] 2411 Mondriaan's Dream
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...
- PHP 线上项目 无法操作
部署到线上的项目,http 环境没有问题,首页展示没有问题,但是跳转页面展示到了本地, 解决办法 : 更改文件夹所属用户 chown -R apache:apache html