2 条题解

  • 1
    @ 2023-5-31 1:30:01
    #include <iostream>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    const int N = 1e5 + 10;
    typedef long long LL;
    int a[N], b[N];
    int n;
    int main(){
        cin >> n;
        for (int i = 1; i <= n; i ++ ) cin >> a[i];
        for (int i = 1; i <= n; i ++ )b[i] = a[i] - a[i - 1];
        LL p = 0,q = 0;
        for (int i = 2; i <= n; i++){
            if(b[i] >0)p += b[i];
            else q -= b[i];
        }
        cout << max(p,q)<<endl;
        cout << abs(p - q)+1<< endl;
        return 0;
    }
    
    
    • -3
      @ 2022-12-1 21:21:45

      ???

    • 1

    信息

    ID
    1240
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    99
    已通过
    70
    上传者