제출 #1270137

#제출 시각아이디문제언어결과실행 시간메모리
1270137almazStove (JOI18_stove)C++20
100 / 100
14 ms2248 KiB
#include <bits/stdc++.h> using namespace std; #define int long long // #define endl '\n' #define ff first #define ss second #define pb push_back #define all(a) a.begin(), a.end() const int MOD = 1e9 + 7,INF = 1e18; void solve(){ int n , k; cin >> n >> k; vector <int> a(n); for(int i = 0;i < n;i++){ cin >> a[i]; } int ans = n; vector <int> b; for(int i = 1;i < n;i++){ b.pb(a[i] - (a[i - 1] + 1)); } sort(all(b)); int h = n - k; for(int i = 0;i < h;i++){ ans += b[i]; } cout<<ans<<endl; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int ti = 1; // cin >> ti; while (ti--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...