原题地址

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. jenkins SVN更改密码后出现的坑爹问题

    1.前提 公司SVN账号密码和AD账号密码是绑定在一起的,为了保证代码检出总是最新,jenkins中做代码检查前总会从SVN中检出最新代码. 最近公司要求AD账户不得使用原始密码,更改密码后,jenk ...

  2. 连接MongoDB数据库的配置说明

  3. 编写Robotium测试程序

    6.编写Robotium测试程序 1)导包 //导入需要测试的工程 import com.example.android.notepad.NotesList; //robotium提供的测试用类 im ...

  4. vue.js学习总结

    下面使用的命令工具为git bash 使用命令行工具搭建vue.js项目 vue.js官网命令行工具安装 为了提升安装速度,建议将 npm 的注册表源设置为国内的镜像 1.输入命令:npm insta ...

  5. codevs 1008 选数

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 已知 n 个整数 x1,x2,…,xn,以及一个整数 k(k<n).从 n ...

  6. 洛谷 P1168 中位数

    题目描述 给出一个长度为N的非负整数序列A[i],对于所有1 ≤ k ≤ (N + 1) / 2,输出A[1], A[3], …, A[2k - 1]的中位数.[color=red]即[/color] ...

  7. 使用office 365打开excel文件报错,提示“向程序发送命令时出现问题”

    我买了一套正版的office 365装在我的windows10 上.但是每次打开excel都会报错,如图一.求教了微软技术人员,他们给出了以下办法: 图一 方法一: 修复安装Office ====== ...

  8. Codeforces Round #316 (Div. 2) B Simple Game 贪心

    贪心,如果m分成的两个区间长度不相等,那么选长的那个区间最接近m的位置,否则选m-1位置,特判一下n等于1的情况 #include<bits/stdc++.h> using namespa ...

  9. Base64编码密钥时关于换行的几个问题。

    在windows下一个javaweb应用,需要用http传递公钥pk.一般是String pk = BASE64ENCODER.encode(pkBytes);base64编码时,每76个字母就要换行 ...

  10. 给 MSYS2 添加国内源

    https://wiki.qt.io/MSYS2pacman -S base-devel git mercurial svn wget p7zip软件包 开发包 http://mirrors.ustc ...