原题地址

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的更多相关文章

  1. HDOJ 1326. Box of Bricks 纯水题

    Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  2. 日常小测:颜色 && Hackerrank Unique_colors

    题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...

  3. HackerRank "Square Subsequences" !!!

    Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the soluti ...

  4. 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 ...

  5. HackerRank "TBS Problem" ~ NPC

    It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/Charl ...

  6. HackerRank Extra long factorials

    传送门 今天在HackerRank上翻到一道高精度题,于是乎就写了个高精度的模板,说是模板其实就只有乘法而已. Extra long factorials Authored by vatsalchan ...

  7. HackerRank "Lucky Numbers"

    Great learning for me:https://www.hackerrank.com/rest/contests/master/challenges/lucky-numbers/hacke ...

  8. HackerRank "Playing with numbers"

    This is 'Difficult' - I worked out it within 45mins, and unlocked HackerRank Algorithm Level 80 yeah ...

  9. HackerRank "The Indian Job"

    A sly knapsack problem in disguise! Thanks to https://github.com/bhajunsingh/programming-challanges/ ...

随机推荐

  1. centos 7 安装JDK (Linux安装jdk)

    centos 7安装JDK (Linux安装jdk) 第一部分 首先查看centos 7是否有openjdk,如没有就跳过第一部分,直接第二部分. [master@bogon ~]$ java -ve ...

  2. linux下phpstudy的搭建以及网站的搭建

    step1: 下载SSH连接到IP地址(阿里云上购买的) step2: 安装下载phpstudywget -c http://lamp.phpstudy.net/phpstudy.bin chmod ...

  3. Sqlserver 2012 Always on技术

    使用了Sqlserver 2012 Always on技术后,假如采用的配置是默认配置,会出现Primary server CPU很高的情况发生,比如默认配置如下: 需要自定义来解决这个问题. 我们先 ...

  4. Cannot fetch index base URL https://pypi.python.org/pypi/ 解决方法

    vi /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # ...

  5. Luogu P5349 幂

    大力数学题,发现自己好久没写多项式水平急速下降,求逆都要写挂233 首先看到关于多项式的等比数列求和,我们容易想到先求出每一项的系数然后最后累加起来即可,即设\(f_i=\sum_{n=0}^{\in ...

  6. maven项目在myeclipse中不出现Maven Dependencies 和maven标识的解决方法

    这种情况通常出现在 我们新加载了一个 maven的项目,但是myeclipse没识别到. 或者说 我们把该项目修改成了maven项目--------也就是说该项目 有了pom.xml 但是还没有mav ...

  7. Encryption-基础:base64加解密

    环境:vc2003 .h /********** This library is free software; you can redistribute it and/or modify it und ...

  8. 2019的hdu暑假作业(欢迎纠错)

    1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...

  9. 前台解析json的方法

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...

  10. -bash: xx: command not found 在有yum源情况下处理

    -bash: xx: command not found 在有yum源情况下处理 yum provides "*/xx"  ###"xx"代表某命令 或者 yu ...