萌新求助!!!

P4445 [AHOI2018初中组] 报名签到

你或许需要使用一下Markdown
by pomelo_nene @ 2019-04-07 12:13:37


希望更丰富的展现?使用Markdown
by andyli @ 2019-04-07 12:17:30


```cpp #include<iostream> using namespace std; int main() { long long a[10001], n, s = 0, max; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 2; i <= n; i++) { max = a[i]; if (a[i - 1] > a[i]) max = a[i - 1]; s += max; } cout << s; } ``` 我帮您重新发一下
by andyli @ 2019-04-07 12:18:34


@[zxwhhh](/space/show?uid=193110) 您可以看一下我的核心代码: ```cpp int n; cin >> n; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 1; i < n; i++) ans += max(A[i - 1], A[i]); cout << ans << endl; ```
by andyli @ 2019-04-07 12:19:50


@[zxwhhh](/space/show?uid=193110) ```cpp const int maxn = 100005; int A[maxn], n; long long ans; ```
by andyli @ 2019-04-07 12:21:07


@[andyli](/space/show?uid=84282) 谢谢大佬,懂了
by zxwhhh @ 2019-04-07 12:38:58


@[andyli](/space/show?uid=84282) ```c # include <stdio.h> int main () { int n; scanf("%d",&n); int old,new_; long long length=0; scanf("%d",&old); for(int i=0;i<n-1;i++) { scanf("%d",&new_); length+=old>new_?old:new_; old=new_; } printf("%d",length); return 0; } ``` 大佬,帮忙看下为什么我用了long long 还会报错呢?
by 水木子 @ 2019-07-28 19:52:03


@[水木子](/space/show?uid=164970) 输出需要改成`printf("%lld",length);`
by andyli @ 2019-07-28 20:46:40


@[andyli](/space/show?uid=84282) 感谢感谢!
by 水木子 @ 2019-07-29 21:27:39


|