题目链接:http://acm.swust.edu.cn/problem/893/

Time limit(ms): 1000      Memory limit(kb): 65535
 

Josh loves playing with blocks. Currently, he has N blocks, labeled 0 through N-1. The heights of all blocks are positive integers. More precisely, for each i, the height of block i is blockHeights[i]. Josh is interested in making the tallest block tower possible. He likes all his towers to follow three simple rules:

1.The blocks must be stacked in a single column, one atop another. The height of the tower is simply the sum of heights of all its blocks. 
2.The labels of blocks used in the tower must increase from the bottom to the top. In other words, whenever Josh places box x on top of box y, we have x > y.
3.Josh will never place a box of an even height on top of a box of an odd height. 
you need find out the height of the tallest possible block tower Josh can build.

Description

Each test case starts with a number N (0 < N <= 1000000) -- the total number of blocks,followed by N positive numbers.All the numbers in the input are less than 1000.A test case with N = 0 denotes the end of input. This test case is not to be processed.

Input

Print the tallest possible block tower on a single line for each test case.

Output
1
2
3
4
5
6
2
4 7
2
7 4
5
49 2 49 2 49
Sample Input
1
2
3
11
7
147
Sample Output
 
 
这题意思太纠结了,始终感觉迷迷糊糊的~~~~求大神解释下题意,下面有一段ac代码
 
 #include <stdio.h>
int dp[][];
#define max(a,b) a>b?a:b
int main()
{
int n, height, i;
while (~scanf("%d", &n), n){
for (i = ; i < n; i++){
scanf("%d", &height);
if (height & ){
if (!i){
dp[i][] = height;
dp[i][] = ;
}
else{
dp[i][] = max(dp[i - ][] + height, dp[i - ][] + height);
dp[i][] = dp[i - ][];
}
}
else{
if (!i){
dp[i][] = height;
dp[i][] = ;
}
else{
dp[i][] = dp[i - ][] + height;
dp[i][] = dp[i - ][];
}
}
}
printf("%d\n", max(dp[n - ][], dp[n - ][]));
}
return ;
}
 

[Swust OJ 893]--Blocks的更多相关文章

  1. [Swust OJ 404]--最小代价树(动态规划)

    题目链接:http://acm.swust.edu.cn/problem/code/745255/ Time limit(ms): 1000 Memory limit(kb): 65535   Des ...

  2. [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)

    题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...

  3. SWUST OJ NBA Finals(0649)

    NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128   Descri ...

  4. [Swust OJ 1023]--Escape(带点其他状态的BFS)

    解题思路:http://acm.swust.edu.cn/problem/1023/ Time limit(ms): 5000 Memory limit(kb): 65535     Descript ...

  5. [Swust OJ 1125]--又见GCD(数论,素数表存贮因子)

    题目链接:http://acm.swust.edu.cn/problem/1125/ Time limit(ms): 1000 Memory limit(kb): 65535   Descriptio ...

  6. [Swust OJ 1126]--神奇的矩阵(BFS,预处理,打表)

    题目链接:http://acm.swust.edu.cn/problem/1126/ Time limit(ms): 1000 Memory limit(kb): 65535 上一周里,患有XX症的哈 ...

  7. [Swust OJ 1026]--Egg pain's hzf

      题目链接:http://acm.swust.edu.cn/problem/1026/     Time limit(ms): 3000 Memory limit(kb): 65535   hzf ...

  8. [Swust OJ 1139]--Coin-row problem

    题目链接:  http://acm.swust.edu.cn/contest/0226/problem/1139/ There is a row of n coins whose values are ...

  9. [Swust OJ 385]--自动写诗

    题目链接:http://acm.swust.edu.cn/problem/0385/ Time limit(ms): 5000 Memory limit(kb): 65535    Descripti ...

随机推荐

  1. 第一节 生命周期和Zend引擎

    一切的开始: SAPI接口 SAPI(Server Application Programming Interface)指的是PHP具体应用的编程接口, 就像PC一样,无论安装哪些操作系统,只要满足了 ...

  2. 指定字符串加密(对称加密DES)

    /* * @(#) EncrypAES.java */ import java.security.InvalidKeyException; import java.security.NoSuchAlg ...

  3. removeCss

    (function ($) { //删除元素行内style中单个style和多个style //示例: //$(".b").removeCss("color") ...

  4. python自学笔记(二)python基本数据类型之字符串处理

    一.数据类型的组成分3部分:身份.类型.值 身份:id方法来看它的唯一标识符,内存地址靠这个查看 类型:type方法查看 值:数据项 二.常用基本数据类型 int 整型 boolean 布尔型 str ...

  5. 前端笔试题 JS部分

    题目 http://www.itmian4.com/forum.php?mod=viewthread&tid=4540 http://www.itmian4.com/forum.php?mod ...

  6. 国内BI工具/报表工具厂商简介

    v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...

  7. 国内外主流BI厂商对比

    BI(Business Intelligence),即商业智能或者商务智能,它是一套完整的解决方案,用来将企业中现有的数据进行有效的整合,快速准确的提供报表并提出决策依据,帮助企业做出明智的业务经营决 ...

  8. 几款Http小服务器

    六款小巧的HTTP Server[C语言] http://blog.linuxphp.org/?action=show&id=60 转载:

  9. DataList嵌套绑定例子

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataList控件.asp ...

  10. MapReduce调度与执行原理之任务调度

    前言 :本文旨在理清在Hadoop中一个MapReduce作业(Job)在提交到框架后的整个生命周期过程,权作总结和日后参考,如有问题,请不吝赐教.本文不涉及Hadoop的架构设计,如有兴趣请参考相关 ...