답안 #1003742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003742 2024-06-20T16:42:50 Z codexistent Stove (JOI18_stove) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <set>
using namespace std;
#define MAXN 100005
#define FOR(i, a, b) for(int i = a; i <= b; i++)

int n, m, arr[MAXN];

int main(){
    cin >> n >> m;
    FOR(i, 1, n) cin >> arr[i];
    sort(arr + 1, arr + 1 + n);

    multiset<int> s;
    FOR(i, 1, n - 1) s.insert(arr[i + 1] - arr[i] - 1);

    int res = arr[n] - arr[1] + 1;
    while(s.size() && m){
        res -= *(s.rbegin());
        s.erase(s.find(*(s.rbegin())));
        m--;
    }

    cout << res << endl;
}

Compilation message

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