比赛 |
test2 |
评测结果 |
AWWWWWWWWW |
题目名称 |
架设电话线路 |
最终得分 |
10 |
用户昵称 |
31627012 |
运行时间 |
0.037 s |
代码语言 |
C++ |
内存使用 |
0.70 MiB |
提交时间 |
2017-03-12 20:34:15 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<algorithm>
- #include<stack>
- #include<queue>
- #include<cstring>
- #include<string>
- #include<cctype>
- #define itn int
- using namespace std;
- int n,c,ans=0;
- int h[100001];int M=-1;
- int main(){
- freopen("phonewire.in","r",stdin);
- freopen("phonewire.out","w",stdout);
- scanf("%d%d",&n,&c);
- for (int i=1;i<=n;i++){
- scanf("%d",&h[i]);M=max(M,h[i]);
- }
- for (int i=2;i<=n;i++){
- ans+=c*abs(h[i]-h[i-1]);
- }
- printf("%d",ans-M);
- }