记录编号 618356 评测结果 AAAAAAAAAA
题目名称 败给了性格恶劣的天才青梅 最终得分 100
用户昵称 Gravatar终焉折枝 是否通过 通过
代码语言 C++ 运行时间 0.222 s
提交时间 2026-08-31 08:38:43 内存使用 5.12 MiB
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include<algo/debug.h>
#else
#define debug(...) 42
#endif

using ll = long long;
using f64 = double;
using f128 = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi  = vector<int>;
using vll = vector<ll>;

#define pb emplace_back
#define mk make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define ciallo(x) cerr << (x) << '\n';

template <typename T, typename U>
inline bool chmin(T& a, const U& b){return (b < a ? a = b, true : false);}
template <typename T, typename U>
inline bool chmax(T& a, const U& b){return (a < b ? a = b, true : false);}

const int N = 1e5 + 5;
int n, k, p;
int a[N];
__int128_t b[N];

inline void print(__int128_t x){
    int sta[64];
    int tot = 0;
    do{
        sta[++ tot] = x % 10;
        x /= 10;
    }while(x);
    while(tot){
        cout << sta[tot];
        tot --;
    }
}

void solve(){
    cin >> n >> k >> p;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
        b[i] = k - a[i];
    }
    for(int i = 1;i <= p + 1;i ++){
        for(int j = n;j >= 1;j --) b[j] = b[j] - b[j - 1];
    }
    __int128_t ans = 0;
    for(int i = 1;i <= n;i ++){
        if(b[i] < 0) b[i] = -b[i];
        ans += b[i];
    }
    print(ans);
}

int main(){
    #ifdef LOCAL
    //freopen("test.txt", "r", stdin);
    #endif
    cin.tie(0) -> sync_with_stdio(0);
    int T = 1;
    // cin >> T;
    while(T --) solve();
    #ifdef LOCAL
        cout << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n ";
    #endif
    return 0;
}