Submission #165910

#TimeUsernameProblemLanguageResultExecution timeMemory
165910Sparky_09Stove (JOI18_stove)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#ifdef LOCAL_DEFINE
#include<conio.h>
#endif
using namespace std;
void io();
void end();
 
 
int main(){
	io();                                     
    int n, k;
    cin>>n>>k;
    vector<int> p, v(n);
    if(n==1){
        cout << 2 << endl
        return 0;
    }
    for(int i = 0; i < n; i++){
        cin>>v[i];
        if(i!=0) p.push_back(v[i]-v[i-1]-1);
    }
    if(k>=n){ cout << n << endl; return 0; }
    sort(p.rbegin(), p.rend());
    int ans = v[n-1];
    for(int i = 0; i < k-1; i++){
        ans-=p[i];
    }
    cout << ans << endl;
	end();
}
 
void io(){
#ifdef LOCAL_DEFINE
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen("input.txt", "rt", stdin);
#endif
}
 
void end(){	
#ifdef LOCAL_DEFINE
	cerr << "\nTime Elapsed: " << 1.0 * clock()/CLOCKS_PER_SEC << " s.\n";
	getch();
#endif
}
 

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:17:9: error: expected ';' before 'return'
         return 0;
         ^~~~~~