답안 #890143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890143 2023-12-20T15:40:54 Z MercubytheFirst Stove (JOI18_stove) C++17
컴파일 오류
0 ms 0 KB
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n + 1);
    for(ll i = 1; i <= n; ++i)
        cin >> v[i];
    vector<ll> diff(n);
    for(ll i = 1; i < n; ++i)
        diff[i] = v[i + 1] - v[i] - 1;
    sort(diff.begin() + 1, diff.end(), greater<ll>());
    ll ans = n;
    for(ll i = k; i < n; ++i){
        ans += diff[i];
    }
    cout << ans << endl;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:17:5: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   17 |     sort(diff.begin() + 1, diff.end(), greater<ll>());
      |     ^~~~
      |     qsort