제출 #922016

#제출 시각아이디문제언어결과실행 시간메모리
922016406Stove (JOI18_stove)C++17
100 / 100
16 ms2388 KiB
#include <bits/stdc++.h> #define int int64_t #define FOR(i, a, b) for (int i = (a); i < (b); ++i) using namespace std; using ar = array<int, 2>; const int64_t INF = 1ll << 60; const int N = 2e5 + 5; int n, a[N], k; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; if (n == 1) { cout << 1; return 0; } FOR(i, 0, n) cin >> a[i]; for (int i = n - 1; i >= 1; --i) a[i] -= a[i - 1] + 1; sort(a + 1, a + n); int x = n; FOR(i, 1, n - k + 1) x += a[i]; cout << x << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...