Submission #1323437

#TimeUsernameProblemLanguageResultExecution timeMemory
1323437python_devopoverStove (JOI18_stove)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) x.begin(), x.end()

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k; cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    if(k >= n){
        cout << n << endl;
        return;
    }
    vector<int> pf(n);
    for(int i = 0; i + 1 < n; i++){
        pf[i] = a[i + 1] - (a[i] + 1);
    }
    sort(all(pf));
    int ans = n;
    for(int i = 0; i < n - k; i++) ans += pf[i];
    cout << ans << endl;
    return;
}

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:16:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   16 |         return;
      |         ^~~~~~
stove.cpp:26:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   26 |     return;
      |     ^~~~~~