P1626求调

题目总版

THE_SUPER_WING @ 2024-11-24 09:27:32

#include <bits/stdc++.h>

using namespace std;

#define LL long long
const int N = 1e6 + 10;

LL a[100000], b[100000];
int main()
{   
    LL n, k;
    cin >> n >> k;
    for(LL i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    LL s = 0, sum = 0;
    for(LL i = 1; i <= n; i++)
    {
        b[++sum] = a[i] - a[i - 1];
    }
    sort(b + 1, b + sum + 1);
    for(int i = 1; i <= n / 2; i++)
    {
        s += b[i];
    }
    cout << s;
    return 0;
}

为啥爆零了


|