이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll
int t, n, m, k, a[300010], q, l, r;
int32_t main(){
INIT
cin>>n>>k;
int ft=0, lt=0;
multiset<int> ms;
for(int i=1; i<=n; i++){
cin>>t;
if(lt>0){
ms.insert(t-lt);
}
if(!ft){
ft=t;
}
lt=t+1;
}
int free=0;
if(!ms.empty()){
auto it=ms.end();
it--;
k--;
while(k>0 ){
k--;
free+=*it;
if(it==ms.begin()){break;}
it--;
}
}
cout<<(lt-ft-free);
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |