제출 #1248783

#제출 시각아이디문제언어결과실행 시간메모리
1248783avohadoStove (JOI18_stove)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define maxn 200005 #define f first #define s second #define ll long long #define pb(x) push_back(x) void solve(){ int n, k; cin >> n >> k; int a[n]; int b[n-1]; for(int i=0; i<n; i++){ cin >> a[i]; } sort(a, a+n); for(int i=1; i<n; i++){ b[i]=a[i]-a[i-1]-1; } sort(b, b+n); long long sum=0; for(int i=0; i<n-k; i++){ sum+=b[i]; } cout << sum+n; } int main(){ cin.tie(nullptr)->sync_with_stdio(0); int t=1; cin >> t; while(t--){ solve(); cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...