Submission #647150

#TimeUsernameProblemLanguageResultExecution timeMemory
647150danikoynovStove (JOI18_stove)C++14
0 / 100
1 ms212 KiB
/** ____ ____ ____ ____ ____ ____ ||l |||e |||i |||n |||a |||d || ||__|||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\|/__\| **/ #include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 1e5 + 10; int n, k, t[maxn], d[maxn]; void solve() { cin >> n >> k; for (int i = 1; i <= n; i ++) cin >> t[i], d[i - 1] = t[i] - t[i - 1] - 1; sort(d + 1, d + n); int ans = t[n]; for (int i = n - 1; i > n - k; i --) ans -= d[i]; cout << ans << endl; } int main() { solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...