NOIP 2013 Day2 前两题偷来的代码
来源:互联网 发布:c语言整型是什么意思 编辑:程序博客网 时间:2024/05/29 10:12
反正我没考试看看代码居然才2、30行就不编了甩上来看看
来第一题题目就不发了自己去找
#include<cstdio>using namespace std;int const N = 100010;int n;int h[N];int tot=0;int main(){freopen("block.in","r",stdin);freopen("block.out","w",stdout);scanf("%d",&n);scanf("%d",&h[1]);tot=h[1];for(int i=2;i<=n;i++){scanf("%d",&h[i]);if(h[i]>h[i-1]) tot+=h[i]-h[i-1];}printf("%d",tot);return 0;}
第二题
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int const N = 100010;int n;int h[N];int ans=0;int main(){freopen("flower.in","r",stdin);freopen("flower.out","w",stdout);scanf("%d",&n);int flag=-1;for(int i=1;i<=n;i++){scanf("%d",&h[i]);if(i!=1&&h[i]>h[i-1]&&flag!=0){//flag 为 0 表示上升 ans++;flag=0;}if(i!=1&&h[i]<h[i-1]&&flag!=1){ans++;flag=1;}}printf("%d",ans+1);return 0;}
0 0
- NOIP 2013 Day2 前两题偷来的代码
- NOIP 2016 Day2 T3 愤怒的小鸟
- 【noip 2013 day2题解】【10.28test】
- codevs 3290 noip 2013 Day2 T3华容道
- 偷来的月亮
- 一个偷来的创意
- 偷来的学习
- 觉得好,偷来的
- 偷来的AWB原理
- NOIP 2011 Day2 Problem1
- NOIP 2011 Day2 Problem2
- 洛谷 NOIP 模拟 DAY2
- NOIP 2017 Day2 总结
- NOIP 2017 Day2 题解?
- 【NOIP 2011 Day2 T2】聪明的质检员(二分)
- NOIP 2011 提高组 复赛 day2 qc 聪明的质监员
- 【codevs 3289】[NOIP 2013 day2 T2] 花匠(dp)
- 【NOIP 2013 Day2 T1】积木大赛(贪心)
- Java基础题目练习
- requirejs入门到精通
- php 高并发解决(商城抢购问题2)
- HDU 2063 过山车(DFS解法)
- android studio cmake 2.2使用案例
- NOIP 2013 Day2 前两题偷来的代码
- adb deviecs时显示的emulator-5554 offline如何解决
- CodeForces
- 数据库中时间字段为null,获取数据库数据映射到类,类中相应的属性的值是null还是时间默认值
- ssh另一台机器时,报Password authentication is disabled to avoid man-in-the-middle attacks.
- python 函数定义
- 编译php7.1.4出现 undefined reference to isfinite
- 什么是java 接口,用处是什么
- LabVIEW2015 TDMS打开报错-2519