Codeforces Round #331 (Div. 2) B. Wilbur and Array
来源:互联网 发布:巨人名录数据库网站 编辑:程序博客网 时间:2024/05/01 06:28
题意:要求一个a数组经过最少多少次可以变成b数组。a数组的初始值全为0,每次改变可以从i到n改变;
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define LL long longint main(){ LL n; while(scanf("%lld",&n)!=EOF) { LL a; LL temp=0; LL sum=0; for(LL i=0;i<n;i++) { scanf("%lld",&a); if(a>temp) { sum+=(a-temp); } else { sum+=(temp-a); } temp=a; } printf("%lld\n",sum); } return 0;}
1 0
- Codeforces Round #331 (Div. 2) B. Wilbur and Array
- Codeforces Round #331 (Div. 2) B. Wilbur and Array
- Codeforces Round #331 (Div. 2) B. Wilbur and Array (贪心)
- Codeforces Round #331 (Div. 2)B. Wilbur and Array(规律)
- Codeforces Round #331 (Div. 2)-Wilbur and Array(贪心模拟)
- 【Codeforces Round 331 (Div 2)B】【水题 贪心】Wilbur and Array 修改对p位置后的所有位置生效 最少修改次数使得数列变成b
- codeforces#331-B. Wilbur and Array-贪心
- Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool
- Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool
- Codeforces Round #331 (Div. 2) C. Wilbur and Points
- Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool
- Codeforces Round #331 (Div. 2) C. Wilbur and Points
- Codeforces Round #331 (Div. 2) C. Wilbur and Points
- Codeforces Round #331 (Div. 2)-C. Wilbur and Points
- Codeforces 596B Wilbur and Array 【贪心】
- CodeForces 596B Wilbur and Array 贪心
- CodeForces 596 B Wilbur and Array
- Codeforces 596 B Wilbur and Array
- struts 多语言切换
- gray code
- 利用ssh传输文件
- android 设置全屏与非全屏
- LeetCode Missing Number 数组
- Codeforces Round #331 (Div. 2) B. Wilbur and Array
- shell&&linux 常用命令
- 爬虫入门讲解:基础理论篇
- animateWithDuration
- 切忌在类的初始化列表中调用类的成员函数
- String、StringBuffer与StringBuilder之间区别
- 选择器实现排序方法
- mysql密码修改
- rwerwqerwqerwer