|洛谷|NOIP2013|贪心|P1969 积木大赛
2016-10-04 15:31
260 查看
http://www.luogu.org/problem/show?pid=1969
如果当前积木高度大于前面的积木高度,说明这块积木要比前面那块积木多操作高出的高度次,而小于等于前面的积木高度,则可以在前面的操作中达到标准
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define ms(i,j) memset(i,j, sizeof i);
using namespace std;
int main()
{
int n;
int x1=0, x2=0;
int ans = 0;
scanf("%d", &n);
for (int i=1;i<=n;i++)
{
scanf("%d", &x1);
if (x1>x2) ans += x1-x2;
x2 = x1;
}
printf("%d\n", ans);
return 0;
}
如果当前积木高度大于前面的积木高度,说明这块积木要比前面那块积木多操作高出的高度次,而小于等于前面的积木高度,则可以在前面的操作中达到标准
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define ms(i,j) memset(i,j, sizeof i);
using namespace std;
int main()
{
int n;
int x1=0, x2=0;
int ans = 0;
scanf("%d", &n);
for (int i=1;i<=n;i++)
{
scanf("%d", &x1);
if (x1>x2) ans += x1-x2;
x2 = x1;
}
printf("%d\n", ans);
return 0;
}
相关文章推荐
- 【P1969】积木大赛 2013NOIP全国联赛提高组(贪心)
- 洛谷 P1969 [NOIP2013 D2T1] 积木大赛
- 洛谷 P1969 [NOIP2013]积木大赛
- [NOIP2013] 提高组 洛谷P1969 积木大赛
- [NOIP2013] 花匠&积木大赛 贪心水题
- [P1969][NOIP2013]积木大赛
- 贪心 NOIP2013 积木大赛
- noip 2013 luogu P1969 积木大赛
- [NOIP 2013]积木大赛 贪心
- NOIP 2013 积木大赛 贪心
- 【基础练习】【贪心】【递推】NOIP2013提高组第五题 积木大赛题解
- 【NOIP2013】 积木大赛 (贪心)
- 【NOIP 2013 Day2 T1】积木大赛(贪心)
- noip2013 积木大赛 (贪心)
- NOIP2013 积木大赛 解题报告(贪心)
- NOIP2013 积木大赛
- NOIP2013Day2T1积木大赛解题报告
- 【模拟】洛谷 P1969 积木大赛
- NOIP 2013 提高组 复赛 day2 block 积木大赛
- 洛谷 P1969 积木大赛