Submission #633747

#TimeUsernameProblemLanguageResultExecution timeMemory
633747tvladm2009Stove (JOI18_stove)C++14
100 / 100
46 ms1720 KiB
#include <iostream> #include <algorithm> using namespace std; const int MAX_N = 1e5; int a[MAX_N + 1]; int n, k; int main() { int ant; cin >> n >> k >> ant; for (int i = 2; i <= n; i++) { int x; cin >> x; a[i - 1] = x - ant - 1; ant = x; } sort(a + 1, a + n); int answer = 0; for (int i = 1; i <= n - k; i++) { answer += a[i]; } cout << answer + n; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...