Submission #649990

#TimeUsernameProblemLanguageResultExecution timeMemory
649990Markomafko972Stove (JOI18_stove)C++14
100 / 100
18 ms2164 KiB
#include <bits/stdc++.h> #define X first #define Y second #define pb push_back #define pii pair<int, int> typedef long long ll; using namespace std; const int MOD = 1e9 + 7; const ll INF = 1e18; const int OFF = (1 << 20); int n, k; int t[100005]; vector<int> v; int main () { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> t[i]; if (i > 0) v.push_back(t[i]-t[i-1]); } sort(v.begin(), v.end()); int kol = n; for (int i = 0; i < n-k; i++) { kol += v[i]-1; } cout << kol; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...