Submission #964166

# Submission time Handle Problem Language Result Execution time Memory
964166 2024-04-16T11:44:27 Z mel Stove (JOI18_stove) C++14
Compilation error
0 ms 0 KB
#include <iostream>
using namespace std;
#define int long long

int arr[100005];
int dif[100005];

signed main() {
        int n; cin >> n;
        int k; cin >> k;
        for (int i =0; i<n; i++){
                cin >> arr[i];
        }
        sort(arr, arr+n);
        for(int i = 0;i<(n-1);i++){
                dif[i] = arr[i+1]-arr[i];
        }
        sort(dif, dif+(n-1));
        if (k>=n) {
                cout << n;
        } else {
                int cnt = k;

                for (int i = 0; i<(n-k); i++) {
                        cnt+= dif[i];
                }
                cout << cnt;
        }
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:14:9: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   14 |         sort(arr, arr+n);
      |         ^~~~
      |         qsort