Codeforces Round #162 (Div. 2) B. Roadside Trees (Simplified Edition)
题目:http://codeforces.com/contest/265/problem/B
#include <iostream> #include <stdio.h> #include <cstring> #include <cmath>using namespace std;int arr[100000]; int main() {int n;cin>>n;for(int i=0;i<n;i++){cin >> arr[i];}int ans=2*n-1+arr[0];for(int i=0;i<n-1;i++){ans+=(abs(arr[i+1]-arr[i]));}cout << ans;return 0; }
转载于:https://www.cnblogs.com/danielqiu/archive/2013/01/21/2870581.html
Codeforces Round #162 (Div. 2) B. Roadside Trees (Simplified Edition)相关推荐
- [Codeforces Round #162 (Div. 2)]A. Colorful Stones (Simplified Edition)
地址:http://codeforces.com/contest/265/problem/A 昨晚没时间参赛 1 #include<stdio.h> 2 #include<strin ...
- # Codeforces Round #548 (Div. 2)C Edgy Trees
Codeforces Round #548 (Div. 2)C Edgy Trees 题目传送门 You are given a tree (a connected undirected graph ...
- 【Codeforces Round #548(Div. 2)】Edgy Trees(数学+bfs求连通块)
题目链接 C. Edgy Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #548 (Div. 2) C. Edgy Trees(dfs || 并查集)
题目链接:https://codeforces.com/contest/1139/problem/C 题意:给了一棵树,n个点,m条边.让从中选k个点,使得从a1到a2,a2到a3,ak-1到ak的路 ...
- Codeforces Round #548 (Div. 2)C. Edgy Trees 并查集
codeforces 1139C 题目链接:http://codeforces.com/contest/1139/problem/C 题意: 给你一个n个结点n-1条边的无向连通图,由红边和黑边组成. ...
- Codeforces Round #548 (Div. 2) C. Edgy Trees(思维+dfs)
题目链接:https://codeforces.com/contest/1139/problem/C 题意是给了一棵树,n个点,m条边.让从中选k个点,使得从a1到a2,a2到a3,ak ...
- Codeforces Round #162 (Div. 2): D. Good Sequences(DP)
题意: 给你n个数字,求出最长相邻不互质子序列 思路: 设dp[i]表示以第i个数字结尾的最长子序列长度 考虑不互质的两个数(x,y),它们一定存在相同的质因子 在DP过程中求出R[p]表示p的倍数当 ...
- Codeforces Round #548 (Div. 2) C. Edgy Trees(并查集+快速幂)
思路用并查集统计一个连通块的节点个数,最后用总的减去他,设x是连通块的节点个数,o个联通块 #include<bits/stdc++.h> #define fi first #define ...
- Codeforces Round #722 (Div. 2)
Codeforces Round #722 (Div. 2) 题号 题目 知识点 A Eshag Loves Big Arrays(题解略) 贪心 B Sifid and Strange Subseq ...
最新文章
- NandFlash详述【转】
- HTAP数据库 PostgreSQL 场景与性能测试之 28 - (OLTP) 高并发点更新
- Confluence 6 复杂授权或性能问题
- WUTOJ 1284: Gold Medal(Java)
- 《王者荣耀》游戏技术总监:技术架构与同步方案上做出改变?
- linux配置服务器超时退出,Linux下实现不活动用户登录超时后自动登出
- 批处理call和start
- EMS1.0.0项目的敏捷实践
- 第四章 自上而下分析
- Python 2.5.7 高阶函数
- Democracy Player 0.8.5
- 关于Savitzky-Golay滤波器
- samba服务器常用指令
- 独自封装windows 10系统详细教程(二)
- 手写SSH2服务器连接池
- raster包—crop函数
- 迄今为止最优秀的配色R包
- 基于STM32F103单片机的智能扫地机器人 循迹避障车 原理图PCB设计
- seaborn调色板 color, hls, cubehelix, dark, diverging_palette
- C++父类与子类间构造,析构,拷贝的调用关系
热门文章
- java设计模式—单例模式
- 计算机输入输出c语言,计算机等级考试二级C语言讲义第三讲输入输出函数
- ROS入门笔记(十三):分布式通信
- 媒体查询能html的ID吗,基于Javascript的媒体查询
- YApi--使用YApi的目的
- centos7.6查看什么进程跑的流量_Spark的提交方式有哪些?有什么区别?
- 质量管理系统_晟通集团内训 | 质量管理系统提升实战训练
- 图片链接用src不能被爬虫爬到吗_爬虫:带你一键爬取王者荣耀英雄皮肤壁纸
- solr5 导入oracle,Solr7使用Oracle数据源导入+中文分词
- 仿lisp运算 java_华为机试题:仿LISP