Submission #718702

#TimeUsernameProblemLanguageResultExecution timeMemory
718702AndrijaMStove (JOI18_stove)C++14
100 / 100
49 ms3140 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(true); long long n; long long k; cin>>n>>k; long long x[n+1]; long long mx=0; long long mi=1e18; for(long long i=1;i<=n;i++) { cin>>x[i]; } vector<long long>a; for(long long i=2;i<=n;i++) { a.push_back(x[i]-x[i-1]-1); } sort(a.rbegin(),a.rend()); long long ans=x[n]-x[1]+1; for(long long i=0;i<k-1;i++) { ans-=a[i]; } cout<<ans<<endl; return 0; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:12:15: warning: unused variable 'mx' [-Wunused-variable]
   12 |     long long mx=0;
      |               ^~
stove.cpp:13:15: warning: unused variable 'mi' [-Wunused-variable]
   13 |     long long mi=1e18;
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...