Submission #1101083

#TimeUsernameProblemLanguageResultExecution timeMemory
1101083akzytrStove (JOI18_stove)C++17
100 / 100
41 ms2268 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n,q; cin >>n >>q; int x = 0; vector<int> t(n); for(int i = 0; i < n; i++){ cin >> t[i]; } int ans = t[n-1] - t[0]+1; vector<int> gaps; for(int i = 1; i < n; i++){ gaps.push_back(t[i] - t[i-1]-1); } sort(gaps.rbegin(), gaps.rend()); for(int i = 0; i < q-1; i++){ ans -= gaps[i]; } cout << ans << endl; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:10:6: warning: unused variable 'x' [-Wunused-variable]
   10 |  int x = 0;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...