Codeforces Round #332 (Div. 2)A. Patrick and Shopping 水
Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between his house and the first shop and a d2 meter long road between his house and the second shop. Also, there is a road of length d3 directly connecting these two shops to each other. Help Patrick calculate the minimum distance that he needs to walk in order to go to both shops and return to his house.
Patrick always starts at his house. He should visit both shops moving only along the three existing roads and return back to his house. He doesn't mind visiting the same shop or passing the same road multiple times. The only goal is to minimize the total distance traveled.
The first line of the input contains three integers d1, d2, d3 (1 ≤ d1, d2, d3 ≤ 108) — the lengths of the paths.
- d1 is the length of the path connecting Patrick's house and the first shop;
- d2 is the length of the path connecting Patrick's house and the second shop;
- d3 is the length of the path connecting both shops.
Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house.
10 20 30
60
1 1 5
4
The first sample is shown on the picture in the problem statement. One of the optimal routes is: house first shop
second shop
house.
In the second sample one of the optimal routes is: house first shop
house
second shop
house.
题意:让你从中间这栋房子经过a,b后回到原点,最小话费距离是多少
题解:
///
#include<bits/stdc++.h>
using namespace std; typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){
if(ch=='-')f=-;ch=getchar();
}
while(ch>=''&&ch<=''){
x=x*+ch-'';ch=getchar();
}return x*f;
}
//****************************************
const int N=+;
#define maxn 100000+5 int main() {
ll a=read(),b=read(),c=read();
ll ans=min(a*+*c,c*+b*);
cout<<min(min(a*+b*,ans),a+b+c)<<endl;
return ;
}
代码
Codeforces Round #332 (Div. 2)A. Patrick and Shopping 水的更多相关文章
- Codeforces Round #332 (Div. 2) A. Patrick and Shopping 水题
A. Patrick and Shopping Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- Codeforces Round #332 (Div. 2) B. Spongebob and Joke 水题
B. Spongebob and Joke Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599 ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #332 (Div. 2)
水 A - Patrick and Shopping #include <bits/stdc++.h> using namespace std; int main(void) { int ...
- Codeforces Round #396 (Div. 2) A B C D 水 trick dp 并查集
A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...
- Codeforces Round #332 (Div. 2) C. Day at the Beach 线段树
C. Day at the Beach Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/p ...
- Codeforces Round #332 (Div. 二) B. Spongebob and Joke
Description While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. ...
- Codeforces Round #332 (Div. 2) D. Spongebob and Squares 数学题枚举
D. Spongebob and Squares Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
- Codeforces Round #332 (Div. 2)_B. Spongebob and Joke
B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
随机推荐
- <stddef.h>
Common definitions 定义类型: ptrdiff_t 两指针相减的结果,signed integer size_t sizeof操作符的结果,unsigned integer max_ ...
- 商业计算中Java高精度计算BigDecimal类
<Effective Java> 第48条:如果需要精确的答案,请避免使用float和double. 如果我们编译运行下面这个程序会看到什么?public class Test{ p ...
- (转)Vue 爬坑之路(四)—— 与 Vuex 的第一次接触
在 Vue.js 的项目中,如果项目结构简单, 父子组件之间的数据传递可以使用 props 或者 $emit 等方式 http://www.cnblogs.com/wisewrong/p/62660 ...
- ie9以下的浏览器兼容性问题
.bind不兼容的问题Function.prototype.bind = function () { var fn = this, args = Array.prototype.slice.call( ...
- STL之string篇
常用代码整理: #include<iostream> #include<cstdio> #include<cstring> #include<string&g ...
- 【PostgreSQL-9.6.3】触发器实例
1. 创建一个触发器,表中的行在任何时候被插入或更新时,当前用户名和时间也会被标记在该行中.并且它会检查雇员的姓名以及薪水. --创建测试表 CREATE TABLE emp ( empname te ...
- html5——网络状态
我们可以通过window.onLine来检测,用户当前的网络状况,返回一个布尔值 window.addEventListener("online",function(){ aler ...
- C# 窗体 切换、重复显示等遗留问题解决(第五天)
一.解决同一窗体多次点击重复显示BUG (1)点击弹出学校窗体 #region 弹出学校窗体 /// <summary> /// 弹出学校窗体 /// </summary> / ...
- WCF开发的流程-服务端和客户端之间的通讯(内含demo讲解)
讲解技术之前,恳请博友让我说几句废话.今天是我第一在博客园发布属于自己原创的博文(如有雷同,那是绝对不可能的事,嘿嘿).之前一直是拜读各位博友的大作,受益匪浅的我在这对博友们说声谢谢,谢谢你们的共享! ...
- Centos6.7 安装zabbix+apache+mysql教程(第一篇)
Centos6.7 安装zabbix+apache+mysql教程 blog地址: http://www.cnblogs.com/caoguo ### 基本包安装 ### [root@ca0gu0 ~ ...