Submission #678061

#TimeUsernameProblemLanguageResultExecution timeMemory
678061hello_there_123Stove (JOI18_stove)C++17
100 / 100
45 ms2216 KiB
#include<bits/stdc++.h> using namespace std; #define int long long main(){ int N,K; cin>>N>>K; int ans = 0; int arr[N+3]; for(int i=0;i<N;i++){ cin>>arr[i]; } ans = arr[N-1]-arr[0]+1; vector<int>v; for(int i=1;i<N;i++){ v.push_back(arr[i]-arr[i-1]-1); } sort(v.begin(),v.end(),greater<int>()); for(int i=0;i<K-1;i++){ ans-=v[i]; } cout<<ans; }

Compilation message (stderr)

stove.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...