이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn = 1e5+10;
#define pb push_back
#define f first
#define s second
int n, k, com, last, resp;
vector<pii> L;
int func(pii a, pii b) {
return a.s - a.f > b.s - b.f;
}
int main () {
cin >> n >> k;
for(int i = 1; i <= n; i++) {
int aux;
cin >> aux;
if(i>1) L.pb({last, aux});
else com = aux;
last = aux+1;
}
resp = last-com;
sort(L.begin(), L.end(), func);
for(int i = 0; i < k-1; i++)
resp -= L[i].s - L[i].f;
cout << resp << 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... |