CF599A.Patrick and Shopping

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 _d_1 meter long road between his house and the first shop and a _d_2 meter long road between his house and the second shop. Also, there is a road of length _d_3 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.

今天,Patrick 正在等待他的朋友 Spongebob 的来访。为了迎接这次来访,Patrick 需要到他家附近的两家商店购买一些零食。他家与第一家商店之间有一条长为 d1d_1 米的道路,他家与第二家商店之间有一条长为 d2d_2 米的道路,此外,这两家商店之间还有一条长度为 d3d_3 米的直连道路。请帮助 Patrick 计算他为了逛完两家商店并返回自己家所需行走的最短总距离。

Patrick 总是从自己家出发。他必须仅沿这三条已有的道路行走,访问两家商店(顺序不限),最后返回自己家。他不介意重复访问同一家商店或重复经过同一条道路。唯一目标是使总行走距离最小。

输入格式

The first line of the input contains three integers _d_1, _d_2, _d_3 (1 ≤ _d_1, _d_2, _d_3 ≤ 108) — the lengths of the paths.

  • _d_1 is the length of the path connecting Patrick's house and the first shop;
  • _d_2 is the length of the path connecting Patrick's house and the second shop;
  • _d_3 is the length of the path connecting both shops.

输入的第一行包含三个整数 d1d_1、d2d_2、d3d_3(1 ≤ d1, d2, d3 ≤ 1081 \leq d_1, d_2, d_3 \leq 10^8)—— 各路径的长度。

  • d1d_1 是连接 Patrick 家与第一家商店的路径长度;
  • d2d_2 是连接 Patrick 家与第二家商店的路径长度;
  • d3d_3 是连接两家商店的路径长度。

输出格式

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

输出 Patrick 为访问两家商店并返回其住所所需行走的最小距离。

输入输出样例

  • 输入#1

    10 20 30

    输出#1

    60
  • 输入#2

    1 1 5

    输出#2

    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.

第一个样例如题目描述中的图片所示。其中一条最优路径为:家 → 第一家商店 → 第二家商店 → 家。

在第二个样例中,其中一条最优路径为:家 → 第一家商店 → 家 → 第二家商店 → 家。

输入解题思路,AI测评打分。不知道怎么写?

首页