Submission #95340

#TimeUsernameProblemLanguageResultExecution timeMemory
95340dalgerokStove (JOI18_stove)C++14
100 / 100
24 ms3316 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 5; int n, k, a[N]; main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> a[i]; } vector < int > q; for(int i = 2; i <= n; i++){ q.push_back(a[i] - a[i - 1] - 1); } int ans = a[n] - a[1] + 1; sort(q.rbegin(), q.rend()); for(int i = 0; i + 1 < k; i++){ ans -= q[i]; } cout << ans; }

Compilation message (stderr)

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