제출 #1150010

#제출 시각아이디문제언어결과실행 시간메모리
1150010tvgkStove (JOI18_stove)C++20
100 / 100
11 ms1096 KiB
#include<bits/stdc++.h> using namespace std; #define task "a" #define se second #define fi first #define ll long long #define ii pair<ll, ll> const long mxN = 1e5 + 7; int n, k, a[mxN], b[mxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(task".INP", "r", stdin); //freopen(task".OUT", "w", stdout); cin >> n >> k; a[0] = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; b[i] = a[i] - a[i - 1]; } sort(b + 2, b + n + 1, greater<int>()); int ans = a[n]; for (int i = 1; i <= k; i++) ans = ans - b[i] + 1; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...