제출 #1219791

#제출 시각아이디문제언어결과실행 시간메모리
1219791mukhamediyarStove (JOI18_stove)C++20
100 / 100
28 ms1968 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; #define int long long #define pb push_back signed main() { int n,k; cin >>n >> k; k --; vector<int>a(n + 1); for(int i = 1; i <= n; i ++){ cin >> a[i]; } int ans = a[n] - a[1] + 1; vector<int>b(n); for(int i = 1; i < n; i ++){ b[i] = a[i + 1] - a[i] - 1; } sort(b.begin() + 1,b.end()); reverse(b.begin() + 1,b.end()); for(int i = 1; i <= k; i ++){ ans -= b[i]; } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...