Submission #1033586

#TimeUsernameProblemLanguageResultExecution timeMemory
1033586vjudge1Stove (JOI18_stove)C++17
0 / 100
1 ms424 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define el '\n' #define pb push_back #define mp make_pair #define niggers \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define file(name) \ freopen(name ".inp", "r", stdin); \ freopen(name ".out", "w", stdout); typedef long long ll; typedef pair<long long, long long> pll; typedef pair<int, int> pii; typedef vector<long long> vll; typedef vector<int> vi; const ll MOD = 1e9 + 7; const int inf = 1e9; const int mxN = 1e2 + 5; const int mxM = 1e3 + 5; const int N = 2e5 + 5; int hx[] = {-1, 0, 1, 0}; int hy[] = {0, 1, 0, -1}; int main() { // freopen("b.inp", "r", stdin); // freopen("b.out", "w", stdout); ll pinkkiu = 1; // cin >> pinkkiu; while (pinkkiu--) { ll n, k; cin >> n >> k; k--; vector<ll> v; ll x; cin >> x; ll last = 0, fifi = x; for (ll i = 2; i <= n; i++) { ll xx; cin >> xx; v.pb(xx - x - 1); x = last = xx; } sort(v.begin(), v.end()); ll ans = last - fifi + 1; while (k--) { ans -= max(0LL, v.back()); v.pop_back(); } cout << ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...