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/ ...
随机推荐
- GetClassName 取得的类名有
今天上午稍微跟踪了一下自己的项目里面的各个空间,得知GetClassName可以取到以下类名:Static\Edit\Button\ComboBox\msctls_trackbar32\SysTabC ...
- 将Android系统源码导入Android studio的方法
Android源码目录结构如下: |-- Makefile|-- abi (applicationbinary interface,应用程序二进制接口,生成libgabi++.so相关库文件)|-- ...
- 最小化安装centos后ifconfig看不到eth0
最小换安装centos后,ifconfig看不到eth0,只看到一个lo ifup eth0
- LR中常见请求的使用示例
Action(){ //application/x-www-form-urlencoded //application/json //web_add_auto_header("Content ...
- sql 函数 coalesce
SQL函数 coalesce 功能: 返回参数中第一个非null的值. 语法: coalesce(参数1,参数2,参数3,...);返回第一个非null的值. 一般情况下会与Nullif()函数一起使 ...
- UVA1665 Islands (并查集)
补题,逆序考虑每个询问的时间,这样每次就变成出现新岛屿,然后用并查集合并统计.fa = -1表示没出现. 以前写过,但是几乎忘了,而且以前写得好丑的,虽然常数比较小,现在重新写练练手.每个单词后面都要 ...
- 补题—Codeforces Round #346 (Div. 2) _智商欠费系列
这次的题目相对容易 但是智商依旧不够用 原因有三点 1.英文水平堪忧 2 逻辑不严密 3 细节掌握不够好 传送门 http://codeforces.com/contest/659 A 题目大意 圆环 ...
- postman使用--构建工作流和newman
构建工作流 在使用“Collection Runner”的时候,集合中的请求执行顺序就是请求在Collection中的显示排列顺序.但是,有的时候我们不希望请求按照这样的方式去执行,可能是执行完第一个 ...
- poi导出word模板项目实例(一个文件)
在页面上填写值,然后导出到word模板中,并把页面上的值带到模板中,也就是导出word文档,提前有word 的模板形式, 1.jsp 页面 <table class="formTa ...
- Oracle 回顾
Oracle 函数 日期函数: 1.sysdate--查询当前日期 select sysdate from dual; --查询当前日期 2.months_between--返回两个日期之间的月份差 ...