Codeforces Round #332 (Div. 2) 599A Patrick and Shopping(模拟)
来源:互联网 发布:mp3编辑软件 编辑:程序博客网 时间:2024/04/30 14:07
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.
题目链接:点击打开链接
给出家与两个商店的距离以及两个商店间的距离, 现在要从家去两个商店最后回到家, 问最短路径是多少.
模拟题, 可能有四种情况, 分别是: home - shop1 - shop2 - home, home - shop1 - home - shop2 - home,
home - shop1 - shop2 - shop1 - home, home - shop2 - shop1 - shop2 - home.
AC代码:
#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"#include "cmath"#include "utility"#include "map"#include "set"#include "vector"using namespace std;typedef long long ll;const int MOD = 1e9 + 7;ll a, b, c;int main(int argc, char const *argv[]){ scanf("%lld%lld%lld", &a, &b, &c); printf("%lld\n", min(2 * (a + b), min(a + b + c, min(2 * (a + c), 2 * (b + c))))); return 0;}
- Codeforces Round #332 (Div. 2) 599A Patrick and Shopping(模拟)
- Codeforces Round #332 (Div. 2) A. Patrick and Shopping
- Codeforces Round #332 (Div. 2) A. Patrick and Shopping
- Codeforces Round #332 (Div. 2) A. Patrick and Shopping
- Codeforces Round #332 (Div. 2)A. Patrick and Shopping(简单题)
- 【Codeforces Round 332 (Div 2)A】【水题】A. Patrick and Shopping 遍历三元环的最小成本
- Patrick and Shopping Codeforces Round #332
- Codeforces 599A Patrick and Shopping 【水题】
- Codeforces 599 A. Patrick and Shopping
- CodeForces 599A Patrick and Shopping
- CodeForces 599A Patrick and Shopping
- 【CodeForces】[599A]Patrick and Shopping
- CodeForces 599A Patrick and Shopping
- 【Codeforces 599A 】Patrick and Shopping
- 599A Patrick and Shopping
- 【CodeForces】599A - Patrick and Shopping(枚举)
- 【Codeforces】-599A-Patrick and Shopping(水)
- 【Codeforces 599A】Patrick and Shopping 最短路程
- JSP基本指令
- Caused by: java.lang.IllegalArgumentException: Can't use FLAG_RECEIVER_BOOT_UPGRADE here的解决
- 通过金矿模型介绍动态规划
- 时间转换,自适应文字高度,手机和邮箱验证
- 在驱动中定义中断
- Codeforces Round #332 (Div. 2) 599A Patrick and Shopping(模拟)
- Kibana User Guide [4.2] » Visualize » Metric
- MyBatis批量操作报错:Parameter 'xxxList' not found. Available parameters are [list]
- Hive之insert into 和insert overwrite
- CAS单点登录(SSO)完整教程
- JAVA wait(), notify(),sleep详解
- java字符串与16进制2进制互转
- HDU 3460 Ancient Printer(思维题或字典树)
- PL/SQL正确选择游标类型