이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pll pair<int, int>
#define pb push_back
#define fi first
#define se second
using namespace std;
ll n, k, total, t[100010];
int main(){
cin >> n >> k; total=n;
vector<int>v;
for(int i=0; i<n; i++){
cin >> t[i];
if(i==0) continue;
int jeda=t[i]-t[i-1]-1;
if(jeda>0) v.pb(jeda);
}
int sz=v.size();
if(k<sz+1){
int kurang=sz+1-k;
sort(v.begin(), v.end());
for(int i=0; i<kurang; i++){
total+=v[i];
}
}
cout << total << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |