A. Patrick and Shopping

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/599/problem/A

Description

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

Input

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.

Output

Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house.

Sample Input

10 20 30

Sample Output

60

HINT

题意

给你从a-b的距离,a-c的距离,b-c的距离,然后问你从a走到bc然后再回到原点的最小距离是多少

题解:

只有4种情况,都考虑一下,然后就好了

代码

#include<iostream>
#include<math.h>
using namespace std; int main()
{
long long d1,d2,d3;
cin>>d1>>d2>>d3;
long long ans = d1+d3+d2;
ans = min(ans,2LL*d1+2LL*d3);
ans = min(ans,2LL*d2+2LL*d3);
ans = min(ans,2LL*d2+2LL*d1);
cout<<ans<<endl;
}

Codeforces Round #332 (Div. 2) A. Patrick and Shopping 水题的更多相关文章

  1. Codeforces Round #332 (Div. 2)A. Patrick and Shopping 水

    A. Patrick and Shopping   Today Patrick waits for a visit from his friend Spongebob. To prepare for ...

  2. 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 ...

  3. 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  ...

  4. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  5. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  6. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

  7. Codeforces Round #368 (Div. 2) A. Brain's Photos 水题

    A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...

  8. Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题

    A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...

  9. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

随机推荐

  1. JQuery实现——黑客帝国代码雨效果

    效果如你所见就是本页面上方那样的效果 实现方法来自一个印度小伙纸,学习完我也没总结一下,今儿个补上 如何实现,大家右键查看源码复制即可,不过学习的过程还是要总结总结. 下面通过另外两个小例子,一步一步 ...

  2. 八位彻底改变App Store的iOS开发者

    我们与 app 交互的方式已经被一群聪明的开发者所完全改变,他们的共性是对 app 都有各自独到的见解.下面就是其中最顶尖的八位. Loren Brichter Tweeite 不是 iOS 上第一个 ...

  3. UITableView 点击展开的实现

    推介看下这里的 内容  http://www.cnblogs.com/kenshincui/p/3931948.html IOS8 above UITabliViewCell 利用 autolayou ...

  4. 如何将自定义RPM包加入YUM

    1 前言 在很多时候进行编译了自己的RPM包,在搭建YUM的时候,希望将自定义的RPM加入到YUM源中,从而出现了下列方法. 2. 将RPM包加入YUM源 2.1 查看目前repodata位置 YUM ...

  5. AWR

    Automatic Workload Repository是10g引入的一个重要组件.在里面存贮着近期一段时间内,默认是7天,数据库活动状态的详细信息 手动得到一份AWR报告: SQL> exe ...

  6. BITED数学建模七日谈之二:怎样阅读数学模型教材

    今天进入我们数学建模七日谈的第二天:怎样阅读数学建模教材? 大家再学习数学建模这门课程或准备比赛的时候,往往都是从教材开始的,教材的系统性让我们能够很快,很深入地了解前人在数学模型方面已有的研究成果, ...

  7. SpannableString 记录(转)

    引用 http://blog.csdn.net/rockcoding/article/details/7231756 TextView是用来显示文本的,有时需要给TextView中的个别字设置为超链接 ...

  8. 解读MMS(Microsoft Media Server)协议

    下面是一次截取的MMS协议开始帧 部分(十六进制): 01000000cefa0bb0c00000004d4d5320 18000000000000000000000000000000 1600000 ...

  9. java开发者最常去的20个英文网站

    java开发者最常去的20个英文网站: 1.[http://www.javaalmanac.com] Java开发者年鉴一书的在线版本. 要想快速查到某种Java技巧的用法及示例代码, 这是一个不错的 ...

  10. 那些经常被遗忘的 Java 面试题

    静态类和静态方法 如果一个类要被声明为static的,只有一种情况,就是静态内部类. 静态内部类实际上与普通类(即类名必须与文件名一样的顶级类)一样,只是静态内部类在某一类的内部定义了而已,既然是类, ...