Submission #1100602

#TimeUsernameProblemLanguageResultExecution timeMemory
1100602uwubigbadboyStove (JOI18_stove)C++17
100 / 100
17 ms7772 KiB
#include <bits/stdc++.h> using namespace std; #define N 500005 #define sz size() #define ll long long int #define ff first #define ss second #define pb push_back #define pt pop_back ll a[N], b[N], c, l, k, tr, b1, c1, d, t, n, h; string s, g; int main() { ios::sync_with_stdio(false);cin.tie(0); cin >> n >> k; c = n - k; h += n; for(int i = 1; i <= n; i++){ cin >> a[i]; } sort(a + 1, a + n + 1); for(int i = 1; i <= n; i++){ if(i + 1 <= n){ l ++; b[l] = a[i + 1] - a[i] - 1; } } sort(b + 1, b + l + 1); // for(int i = 1; i <= l; i++)cout << b[i] << ' '; // return 0; for(int i = 1; i <= c; i++){ h += b[i]; } cout << h<< '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...