Submission #284594

#TimeUsernameProblemLanguageResultExecution timeMemory
284594triplem5dsStove (JOI18_stove)C++14
100 / 100
96 ms2292 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include "bits/stdc++.h" using namespace std; #define pb push_back #define F first #define S second #define f(i,a,b) for(int i = a; i < b; i++) #define endl '\n' using ll = long long; using db = long double; using ii = pair<int, int>; const int N = 2e5 + 5, LG = 19, MOD = 1e9 + 7; const int SQ =225; const long double EPS = 1e-7; string s; int32_t main(){ #ifdef ONLINE_JUDGE ios_base::sync_with_stdio(0); cin.tie(0); #endif int n, k; cin >> n >> k; vector<int> v(n); vector<int> times; int ans = n; for(int i = 0; i < n; i++){ cin >> v[i]; if(i)times.push_back(v[i] - v[i-1] - 1); } sort(times.begin(),times.end()); k = n - k; times.resize(k); cout << ans + accumulate(times.begin(),times.end(),0ll) << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...