제출 #1124811

#제출 시각아이디문제언어결과실행 시간메모리
1124811username_____hereStove (JOI18_stove)C++20
100 / 100
16 ms1096 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> veci; typedef vector<ll> vecll; #define fi first #define se second #define vec vector #define pq priority_queue int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; k = n-k; int a[n], diff[n-1], i; for (i=0; i<n; i++) { cin >> a[i]; } for (i=0; i<n-1; i++) { diff[i] = a[i+1]-a[i]; } sort(diff, diff+n-1); int ans=n; for (i=0; i<k; i++) { ans += diff[i]-1; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...