三种情况:—,列车在人的后面。二,列车与人重合。三,列车宰人的前面。不同情况下比较列车与走路所耗费的时间。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63#include<bits/stdc++.h> using namespace std; int main() { int s,x1,x2,t1,t2,p,d; cin>>s>>x1>>x2; cin>>t1>>t2; cin>>p>>d; if(t1>=t2) { cout<<abs(x1-x2)*t2<<endl; } else { int opt,time; if(x1>x2) opt=-1; else opt=1; if(opt+d==0) { if(d==-1) time=min((p+x1+abs(x1-x2))*t1,abs(x1-x2)*t2); else time=min((s-p+s-x1+abs(x1-x2))*t1,abs(x1-x2)*t2); cout<<time<<endl; } else { if(d==-1) { if(x1<p&&t1<t2) { time=min((p-x2)*t1,(x1-x2)*t2); } else if(x1==p) { time=min((x1-x2)*t1,(x1-x2)*t2); } else { time=min((x1-x2)*t2,(p+s+s-x1+x1-x2)*t1); } } else { if(x1>p&&t1<t2) { time=min((x2-p)*t1,(x2-x1)*t2); } else if(x1==p) { time=min((x2-x1)*t1,(x2-x1)*t2); } else { time=min((x2-x1)*t2,(s-p+s+x2)*t1); } } cout<<time<<endl; } } return 0; }
最后
以上就是任性烤鸡最近收集整理的关于746 C. Tram codeforces的全部内容,更多相关746内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复